@infodb/p3 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -35
- package/dist/web/assets/CompletionReview-gZKZrDu_.js +1 -0
- package/dist/web/assets/ImprovementDialog-Dno6dPnG.js +1 -0
- package/dist/web/assets/Outputs-BgHalMGb.js +1 -0
- package/dist/web/assets/RequestStatus-hZcBUUIu.js +1 -0
- package/dist/web/assets/Tabs-C3NmwCc3.js +1 -0
- package/dist/web/assets/TagInput-B2b862qn.js +1 -0
- package/dist/web/assets/TaskDrawer-4BQBELXa.js +6 -0
- package/dist/web/assets/_requestId-BMAG1t3o.js +1 -0
- package/dist/web/assets/_requestId-tbg2pA2S.js +1 -0
- package/dist/web/assets/archive-DMl6WyOe.js +1 -0
- package/dist/web/assets/board-BMTcHKyt.js +1 -0
- package/dist/web/assets/done-CL6Nlsua.js +1 -0
- package/dist/web/assets/draft-BvGxfD7v.js +2 -0
- package/dist/web/assets/index-Dp7Fc4VI.css +2 -0
- package/dist/web/assets/index-KdlgMitg.js +12 -0
- package/dist/web/assets/metrics-Cu7gJ7Rk.js +1 -0
- package/dist/web/assets/new-DTXWHuFO.js +1 -0
- package/dist/web/assets/outputs-CXqnjSqV.js +1 -0
- package/dist/web/assets/preflightInput-ClKwkp8R.js +2 -0
- package/dist/web/assets/preload-helper-oLCrNCwz.js +1 -0
- package/dist/web/assets/{quality-Pu6EISAM.js → quality-RFd-7k3r.js} +1 -1
- package/dist/web/assets/release-notes-Bpdi6RdY.js +5 -0
- package/dist/web/assets/requestData-CbFxwW5w.js +1 -0
- package/dist/web/assets/routes-BIt8bExF.js +6 -0
- package/dist/web/assets/settings-CsCqF_1B.js +1 -0
- package/dist/web/assets/ui-BGK72r3u.js +1 -0
- package/dist/web/assets/workTarget-CySfKyfB.js +30 -0
- package/dist/web/index.html +4 -4
- package/docs/architecture.md +300 -36
- package/docs/development.md +60 -16
- package/docs/how-to-use.md +381 -28
- package/docs/installation.md +235 -144
- package/docs/publishing.md +1 -1
- package/lib/cli/agentsStatus.js +197 -0
- package/lib/cli/args.js +72 -8
- package/lib/cli/guide.js +27 -0
- package/lib/cli/guide.md +214 -0
- package/lib/cli/help.js +44 -6
- package/lib/cli/main.js +76 -20
- package/lib/cli/metricsCommands.js +77 -0
- package/lib/cli/output.js +12 -2
- package/lib/cli/project.js +13 -27
- package/lib/cli/qualityCommands.js +33 -8
- package/lib/cli/readOnly.js +15 -0
- package/lib/cli/requestCommands.js +21 -4
- package/lib/cli/requirementCommands.js +288 -0
- package/lib/cli/retroCommands.js +106 -0
- package/lib/cli/revisitCommands.js +73 -0
- package/lib/cli/showView.js +119 -6
- package/lib/cli/taskCommands.js +42 -16
- package/lib/cli/userConfig.js +47 -0
- package/lib/core/completionRefs.js +46 -0
- package/lib/core/metrics/definitions.js +434 -0
- package/lib/core/metrics/index.js +88 -0
- package/lib/core/metrics/manual.js +180 -0
- package/lib/core/ops.js +15 -2
- package/lib/core/preflight/carryover.js +5 -1
- package/lib/core/preflight/codexEngine.js +34 -17
- package/lib/core/preflight/diagnose.js +4 -9
- package/lib/core/preflight/engine.js +9 -0
- package/lib/core/preflight/hostPaths.js +260 -0
- package/lib/core/preflight/input.js +33 -5
- package/lib/core/preflight/instructions.js +18 -1
- package/lib/core/preflight/mockEngine.js +20 -2
- package/lib/core/preflight/render.js +22 -3
- package/lib/core/preflight/service.js +59 -9
- package/lib/core/preflight/uiRender.js +3 -0
- package/lib/core/requestOps.js +206 -14
- package/lib/core/retrospective.js +208 -0
- package/lib/core/reviewCandidates.js +56 -0
- package/lib/core/store/collection.js +20 -1
- package/lib/core/store/normalize.js +22 -4
- package/lib/core/store/preflightStore.js +19 -5
- package/lib/core/store/workspace.js +17 -1
- package/lib/core/taskReview/material.js +7 -0
- package/lib/core/taskReview/review.js +9 -2
- package/lib/server/api/manifest.js +51 -3
- package/lib/server/api/routes.js +131 -11
- package/lib/shared/acceptance.js +258 -18
- package/lib/shared/completionRecord.js +327 -0
- package/lib/shared/metrics.js +42 -0
- package/lib/shared/preflightInput.js +1 -1
- package/lib/shared/requirementSource.js +635 -0
- package/lib/shared/retrospective.js +286 -0
- package/lib/shared/reviewCandidate.js +308 -0
- package/lib/shared/reworkHistory.js +81 -0
- package/package.json +3 -2
- package/skills/p3/SKILL.md +9 -181
- package/dist/web/assets/ImprovementDialog-kQaVBGWH.js +0 -1
- package/dist/web/assets/Outputs-_nU_p3nu.js +0 -1
- package/dist/web/assets/RequestStatus-RG-OVQYY.js +0 -1
- package/dist/web/assets/Tabs-ew9i5SKX.js +0 -1
- package/dist/web/assets/TagInput-BtlJTF7i.js +0 -1
- package/dist/web/assets/TaskDrawer-DW8GyJqI.js +0 -6
- package/dist/web/assets/_requestId-6Nb727dD.js +0 -1
- package/dist/web/assets/_requestId-BykTgPax.js +0 -1
- package/dist/web/assets/appCtx-CxDdXABS.js +0 -1
- package/dist/web/assets/archive-Ckh295Xe.js +0 -1
- package/dist/web/assets/board-BVAIjK-Y.js +0 -1
- package/dist/web/assets/done-BGfA-3MA.js +0 -1
- package/dist/web/assets/draft-CfJeyLOl.js +0 -1
- package/dist/web/assets/index-CgRU744I.css +0 -2
- package/dist/web/assets/index-DacQ0yl4.js +0 -12
- package/dist/web/assets/new-DVygWvVc.js +0 -1
- package/dist/web/assets/outputs-B6xDsLZf.js +0 -1
- package/dist/web/assets/preflightInput-BAeEJYUK.js +0 -2
- package/dist/web/assets/preload-helper-DyCqp21K.js +0 -1
- package/dist/web/assets/release-notes-CCpzyiNf.js +0 -5
- package/dist/web/assets/requestData-D5vBnuMh.js +0 -1
- package/dist/web/assets/routes-Q91zvNc0.js +0 -4
- package/dist/web/assets/settings-BzRgcmUm.js +0 -1
- package/dist/web/assets/workTarget-C9c57JAO.js +0 -30
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ACCEPTANCE_KEYS, readAcceptance } from "../../shared/acceptance.js";
|
|
2
2
|
import { BLOCK_KEYS, readBlock } from "../../shared/taskBlock.js";
|
|
3
|
+
import { COMPLETION_KEYS, readCompletion } from "../../shared/completionRecord.js";
|
|
4
|
+
import { PREMISE_KEYS, readPremises } from "../../shared/reviewCandidate.js";
|
|
5
|
+
import { readRework, REWORK_KEYS } from "../../shared/reworkHistory.js";
|
|
3
6
|
import { qualityVersion, readQuality } from "../../shared/quality.js";
|
|
7
|
+
import { readRequirement, REQUIREMENT_KEYS } from "../../shared/requirementSource.js";
|
|
4
8
|
import { repoNameProblem } from "../../shared/repos.js";
|
|
5
9
|
import { isPreflightRunner } from "../../shared/preflightRunner.js";
|
|
6
10
|
import { isTaskStatus, RELATION_TYPES, REQUEST_STATUSES } from "../../shared/types.js";
|
|
@@ -43,6 +47,8 @@ export const normalizeTaskIn = (requestId) => (d, body, id) => ({
|
|
|
43
47
|
record: str(d.record)?.trim() || undefined,
|
|
44
48
|
...readAcceptance(d),
|
|
45
49
|
...readBlock(d),
|
|
50
|
+
...readCompletion(d),
|
|
51
|
+
...readRework(d),
|
|
46
52
|
relations: normalizeRelations(d.relations),
|
|
47
53
|
rev: num(d.rev) ?? 1,
|
|
48
54
|
createdAt: iso(d.createdAt),
|
|
@@ -51,12 +57,17 @@ export const normalizeTaskIn = (requestId) => (d, body, id) => ({
|
|
|
51
57
|
body,
|
|
52
58
|
});
|
|
53
59
|
/** タスクのうちファイルに書かないキー(場所から決まるもの・読んだときの問題) */
|
|
54
|
-
export const TASK_DERIVED = ["request", "ref", "acceptanceProblems", "blockProblems"];
|
|
60
|
+
export const TASK_DERIVED = ["request", "ref", "acceptanceProblems", "blockProblems", "completionProblems", "reworkProblems"];
|
|
55
61
|
/** 基準・証拠が壊れていたら、関係のない更新ではファイルの元の値のまま書き戻す(shared/acceptance.ts) */
|
|
56
|
-
export const taskKeepRaw = (t) => [
|
|
62
|
+
export const taskKeepRaw = (t) => [
|
|
63
|
+
...(t.acceptanceProblems?.length ? ACCEPTANCE_KEYS : []),
|
|
64
|
+
...(t.blockProblems?.length ? BLOCK_KEYS : []),
|
|
65
|
+
...(t.completionProblems?.length ? COMPLETION_KEYS : []),
|
|
66
|
+
...(t.reworkProblems?.length ? REWORK_KEYS : []),
|
|
67
|
+
];
|
|
57
68
|
export const TASK_KEY_ORDER = [
|
|
58
69
|
"id", "title", "status", "repo", "labels", "areas", "outputs", "repoOutputs", "record",
|
|
59
|
-
"acceptanceCriteria", "acceptanceEvidence", "acceptanceSeq", "block", "blockHistory", "relations", "rev", "createdAt", "startedAt", "doneAt", "checkedAt", "updatedAt", "updatedBy",
|
|
70
|
+
"acceptanceCriteria", "acceptanceEvidence", "acceptanceSeq", "acceptanceSources", "block", "blockHistory", "relations", "rev", "createdAt", "startedAt", "doneAt", "checkedAt", "updatedAt", "updatedBy", "reworkHistory", "completionRecords",
|
|
60
71
|
];
|
|
61
72
|
export function normalizeRequest(d, body, id) {
|
|
62
73
|
const status = str(d.status);
|
|
@@ -75,6 +86,9 @@ export function normalizeRequest(d, body, id) {
|
|
|
75
86
|
tags: strs(d.tags),
|
|
76
87
|
...(d.workstreams && typeof d.workstreams === "object" ? { workstreams: normalizeWorkstreams(d.workstreams) } : {}),
|
|
77
88
|
lastPreflight: str(d.lastPreflight),
|
|
89
|
+
...readRequirement(d),
|
|
90
|
+
...readCompletion(d),
|
|
91
|
+
...readPremises(d),
|
|
78
92
|
rev: num(d.rev) ?? 1,
|
|
79
93
|
createdAt: iso(d.createdAt),
|
|
80
94
|
updatedAt: iso(d.updatedAt),
|
|
@@ -84,8 +98,12 @@ export function normalizeRequest(d, body, id) {
|
|
|
84
98
|
}
|
|
85
99
|
export const REQUEST_KEY_ORDER = [
|
|
86
100
|
"id", "title", "status", "parent", "childOrder", "splitFrom", "due", "milestone", "tags", "areas", "workstreams", "lastPreflight",
|
|
87
|
-
"rev", "createdAt", "updatedAt", "updatedBy",
|
|
101
|
+
"requirementSources", "requirementSeq", "clarifyAnswers", "rev", "createdAt", "updatedAt", "updatedBy", "premiseChanges", "completionRecords",
|
|
88
102
|
];
|
|
103
|
+
/** 要望のうちファイルに書かないキー(読んだときの問題) */
|
|
104
|
+
export const REQUEST_DERIVED = ["requirementProblems", "completionProblems", "premiseProblems"];
|
|
105
|
+
/** 要求の根拠・回答が壊れていたら、関係のない更新ではファイルの元の値のまま書き戻す(shared/requirementSource.ts) */
|
|
106
|
+
export const requestKeepRaw = (r) => [...(r.requirementProblems?.length ? REQUIREMENT_KEYS : []), ...(r.completionProblems?.length ? COMPLETION_KEYS : []), ...(r.premiseProblems?.length ? PREMISE_KEYS : [])];
|
|
89
107
|
/** preflight.runner(未設定は書かない。読めない値は invalidRunner に残し、担当を推測しない) */
|
|
90
108
|
function runnerOf(v) {
|
|
91
109
|
const raw = str(v)?.trim();
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { readdir, readFile, mkdir, rm, stat } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { readDraftCriteria } from "../../shared/acceptance.js";
|
|
4
|
+
import { readCriterionSources } from "../../shared/requirementSource.js";
|
|
4
5
|
import { parseFrontmatter, stringifyFrontmatter } from "./frontmatter.js";
|
|
5
|
-
/**
|
|
6
|
-
function draftCriteriaOf(raw) {
|
|
7
|
-
const { criteria, problems } = readDraftCriteria(raw);
|
|
8
|
-
|
|
6
|
+
/** 案の受け入れ基準と要求の根拠(無い古い案は何も足さない。読めない項目は acceptanceProblems に理由) */
|
|
7
|
+
function draftCriteriaOf(raw, rawSources) {
|
|
8
|
+
const { criteria, problems = [] } = readDraftCriteria(raw);
|
|
9
|
+
const sourceProblems = [];
|
|
10
|
+
const sources = readCriterionSources(rawSources, sourceProblems);
|
|
11
|
+
const all = [...problems, ...sourceProblems];
|
|
12
|
+
return { ...(criteria ? { acceptanceCriteria: criteria } : {}), ...(sources ? { acceptanceSources: sources } : {}), ...(all.length ? { acceptanceProblems: all } : {}) };
|
|
9
13
|
}
|
|
10
14
|
import { writeFileAtomic } from "./fsutil.js";
|
|
11
15
|
/**
|
|
@@ -42,6 +46,16 @@ export class PreflightStore {
|
|
|
42
46
|
const { description, acceptanceProblems: _p, ...meta } = d;
|
|
43
47
|
await writeFileAtomic(join(this.runDir(requestId, runId), "drafts", `${d.key}.md`), stringifyFrontmatter({ ...meta, include: d.include }, description));
|
|
44
48
|
}
|
|
49
|
+
/** 案のファイルの frontmatter の元の値(読めなかった項目を、関係のない更新で消さないため) */
|
|
50
|
+
async rawDraftField(requestId, runId, key, field) {
|
|
51
|
+
const text = await readFile(join(this.runDir(requestId, runId), "drafts", `${key}.md`), "utf8").catch(() => undefined);
|
|
52
|
+
return text === undefined ? undefined : parseFrontmatter(text).data[field];
|
|
53
|
+
}
|
|
54
|
+
/** extra: 読めた値の代わりに元の値のまま書く項目 */
|
|
55
|
+
async saveDraftRaw(requestId, runId, d, extra) {
|
|
56
|
+
const { description, acceptanceProblems: _p, ...meta } = d;
|
|
57
|
+
await writeFileAtomic(join(this.runDir(requestId, runId), "drafts", `${d.key}.md`), stringifyFrontmatter({ ...meta, ...extra, include: d.include }, description));
|
|
58
|
+
}
|
|
45
59
|
async loadDrafts(requestId, runId) {
|
|
46
60
|
const dir = join(this.runDir(requestId, runId), "drafts");
|
|
47
61
|
const files = await readdir(dir).catch(() => []);
|
|
@@ -57,7 +71,7 @@ export class PreflightStore {
|
|
|
57
71
|
supersedes: Array.isArray(data.supersedes) ? data.supersedes.map(String) : [],
|
|
58
72
|
include: data.include !== false,
|
|
59
73
|
...("repo" in data ? { repo: data.repo === null || data.repo === "" || data.repo === "none" ? null : String(data.repo) } : {}),
|
|
60
|
-
...draftCriteriaOf(data.acceptanceCriteria),
|
|
74
|
+
...draftCriteriaOf(data.acceptanceCriteria, data.acceptanceSources),
|
|
61
75
|
});
|
|
62
76
|
}
|
|
63
77
|
return drafts.sort((a, b) => a.key.localeCompare(b.key, undefined, { numeric: true }));
|
|
@@ -7,7 +7,7 @@ import { milestoneGoalProblems, tidyMilestoneGoals } from "../../shared/mileston
|
|
|
7
7
|
import { QualityInputError, qualityPlain } from "../../shared/quality.js";
|
|
8
8
|
import { fileLayout, folderLayout, MarkdownCollection, NotFoundError } from "./collection.js";
|
|
9
9
|
import { newRequestId, withFileLock } from "./fsutil.js";
|
|
10
|
-
import { normalizeProject, normalizeRequest, normalizeTaskIn, REQUEST_KEY_ORDER, TASK_DERIVED, TASK_KEY_ORDER, taskKeepRaw } from "./normalize.js";
|
|
10
|
+
import { normalizeProject, normalizeRequest, normalizeTaskIn, REQUEST_KEY_ORDER, REQUEST_DERIVED, requestKeepRaw, TASK_DERIVED, TASK_KEY_ORDER, taskKeepRaw } from "./normalize.js";
|
|
11
11
|
import { AttachmentStore } from "./attachments.js";
|
|
12
12
|
import { DataWatcher } from "./dataWatcher.js";
|
|
13
13
|
import { NoteStore } from "./noteStore.js";
|
|
@@ -94,6 +94,10 @@ export class Workspace {
|
|
|
94
94
|
layout: folderLayout(this.requestsDir, "request.md", REQUEST_ID, () => newRequestId()),
|
|
95
95
|
normalize: normalizeRequest,
|
|
96
96
|
keyOrder: REQUEST_KEY_ORDER,
|
|
97
|
+
derived: REQUEST_DERIVED,
|
|
98
|
+
keepRaw: requestKeepRaw,
|
|
99
|
+
// 要望ごとのロック(タスクと同じ。要望のフォルダの外に置くので、アーカイブで一緒に動かない)
|
|
100
|
+
lock: (id) => (id ? this.requestLock(id) : undefined),
|
|
97
101
|
});
|
|
98
102
|
this.preflight = new PreflightStore(this.requestsDir);
|
|
99
103
|
this.notes = new NoteStore(this.requestsDir);
|
|
@@ -105,6 +109,13 @@ export class Workspace {
|
|
|
105
109
|
get requestsDir() {
|
|
106
110
|
return join(this.dataDir, "requests");
|
|
107
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* 要望とそのタスクの保存のロック(requests/.locks/<要望ID>.lock)。読み直してから書く・移すまでを、別のプロセスと1つずつにする。
|
|
114
|
+
* ロックの順: 親子の操作のロック(.hierarchy.lock)→ この要望のロック。このロックの中で別の要望・タスクのロックは取らない
|
|
115
|
+
*/
|
|
116
|
+
requestLock(rid) {
|
|
117
|
+
return join(this.requestsDir, ".locks", `${rid}.lock`);
|
|
118
|
+
}
|
|
108
119
|
/** このマシンのパスを変えた(個人設定に書いた後に呼ぶ) */
|
|
109
120
|
setLocalRepo(name, path) {
|
|
110
121
|
const next = { ...this.localRepos };
|
|
@@ -212,6 +223,7 @@ export class Workspace {
|
|
|
212
223
|
derived: TASK_DERIVED,
|
|
213
224
|
keepRaw: taskKeepRaw,
|
|
214
225
|
beforeWrite: (prev, next) => stampStatus(prev, next),
|
|
226
|
+
lock: () => this.requestLock(requestId),
|
|
215
227
|
});
|
|
216
228
|
this.taskCollections.set(requestId, col);
|
|
217
229
|
}
|
|
@@ -394,6 +406,10 @@ export class Workspace {
|
|
|
394
406
|
await this.tasksOf(rid).reload(id);
|
|
395
407
|
this.emit({ type: "changed", kind: "task", request: rid, ref: `${rid}/${id}` });
|
|
396
408
|
}
|
|
409
|
+
else if (kind === "retrospective.json") {
|
|
410
|
+
// 振り返りの記録(ほかのプロセスの確定・確認)
|
|
411
|
+
this.emit({ type: "changed", kind: "request", request: rid });
|
|
412
|
+
}
|
|
397
413
|
else if (kind === "preflight") {
|
|
398
414
|
this.emit({ type: "changed", kind: "preflight", request: rid });
|
|
399
415
|
}
|
|
@@ -4,6 +4,7 @@ import { readFile } from "node:fs/promises";
|
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import YAML from "yaml";
|
|
6
6
|
import { acceptanceStatus } from "../../shared/acceptance.js";
|
|
7
|
+
import { criteriaSourceView } from "../../shared/requirementSource.js";
|
|
7
8
|
import { qualitySnapshot, standardsFor, taskQualityDiff } from "../../shared/quality.js";
|
|
8
9
|
import { commitsInOutput } from "../milestoneReview/code.js";
|
|
9
10
|
import { NotFoundError } from "../store/collection.js";
|
|
@@ -210,6 +211,7 @@ export async function extractTaskReview(dataDir, rid, tid, refs, opts = {}) {
|
|
|
210
211
|
...(task.acceptanceCriteria?.length ? { criteria: task.acceptanceCriteria } : {}),
|
|
211
212
|
...(task.acceptanceEvidence?.length ? { evidence: task.acceptanceEvidence } : {}),
|
|
212
213
|
...(acc?.items.length ? { evidenceStates: acc.items.map((i) => ({ id: i.id, state: i.state })) } : {}),
|
|
214
|
+
...(task.acceptanceSources?.length ? { sources: sourcesForReview(task, request ? (request.requirementSources ?? []).map((x) => x.id) : undefined) } : {}),
|
|
213
215
|
...(task.acceptanceProblems?.length ? { acceptanceProblems: task.acceptanceProblems } : {}),
|
|
214
216
|
},
|
|
215
217
|
items,
|
|
@@ -224,6 +226,11 @@ export async function extractTaskReview(dataDir, rid, tid, refs, opts = {}) {
|
|
|
224
226
|
* 材料の識別子(抽出の日時は入れない)。比較対象の出典(成果物の文字列か、指定した文字列か)も入れない
|
|
225
227
|
* (同じ SHA を比べていれば、指定の仕方によらず同じ材料)
|
|
226
228
|
*/
|
|
229
|
+
/** 基準ごとの要求の根拠の記録と状態(材料のスナップショットに入れ、hash にも入る) */
|
|
230
|
+
function sourcesForReview(task, requestSourceIds) {
|
|
231
|
+
const view = criteriaSourceView(task.acceptanceCriteria, task.acceptanceSources, requestSourceIds);
|
|
232
|
+
return [...view.items.flatMap((i) => i.sources), ...view.orphans];
|
|
233
|
+
}
|
|
227
234
|
export function taskReviewInputHash(i) {
|
|
228
235
|
const targets = i.targets.map(({ sources: _s, ...t }) => t);
|
|
229
236
|
const notes = i.notes.filter((n) => n.code !== "pr_unresolved");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { evidenceBasisOf } from "../../shared/acceptance.js";
|
|
1
2
|
import { CONTAINER_WORKSPACE } from "@infodb/codex-workspace";
|
|
2
3
|
import { QUALITY_VERDICTS, TASK_REVIEW_VERDICTS, } from "../../shared/taskReview.js";
|
|
3
4
|
/**
|
|
@@ -29,8 +30,14 @@ export function taskReviewMaterial(input) {
|
|
|
29
30
|
record: input.task.record ?? null,
|
|
30
31
|
outputs: input.task.outputs,
|
|
31
32
|
// 作業した側の申告(判定ではない)
|
|
32
|
-
|
|
33
|
+
// basis は根拠の種類(作業した側の申告。basisRecorded: false は根拠を記録する前の古い証拠で、申告のみと読む)
|
|
34
|
+
workerEvidence: (input.task.evidence ?? []).map((e) => {
|
|
35
|
+
const { basis, recorded } = evidenceBasisOf(e);
|
|
36
|
+
return { criterion: e.criterionId, result: e.result, evidence: e.evidence, basis, basisRecorded: recorded };
|
|
37
|
+
}),
|
|
33
38
|
evidenceStates: input.task.evidenceStates ?? [],
|
|
39
|
+
// 基準ごとの要求の根拠(要望者の申告。確認記録ありも P3 の保証ではない。レビューの判定を確かめた人として書かない)
|
|
40
|
+
requirementSources: (input.task.sources ?? []).map((s) => ({ criterion: s.criterionId, id: s.id, state: s.state, target: s.target ?? null, source: s.source ?? null, basis: s.basis ?? null, confirmed: s.confirmed ? { by: s.confirmed.by, on: s.confirmed.on } : null })),
|
|
34
41
|
acceptanceProblems: input.task.acceptanceProblems ?? [],
|
|
35
42
|
},
|
|
36
43
|
items: input.items,
|
|
@@ -91,7 +98,7 @@ export function taskReviewPrompt(input) {
|
|
|
91
98
|
const instructions = `あなたはタスクのレビュー係です。完了したタスクの本文・受け入れ基準(比較項目)が、比較対象の変更(固定したコミットの差分と、その前後のコード)で満たされているかを確かめ、日本語で評価します。
|
|
92
99
|
これは作業した人や AI の能力・成績の評価ではありません。「依頼された基準が成果物で満たされているか」だけを確かめます。
|
|
93
100
|
- 読めるのは ${materialPath} の固定した材料だけです(差分の本文 patch と、変わったファイルの前後の中身 before / after)。リポジトリそのものはマウントしていません。材料に無いファイルは読めないので、判断できないことは undetermined にしてください。
|
|
94
|
-
- 作業した側の証拠(workerEvidence
|
|
101
|
+
- 作業した側の証拠(workerEvidence)・変更の記録・成果物は自己申告です。どこを見るかの手がかりに使い、書いてあることを事実として扱わないでください。根拠(basis)の「検査結果あり(machine)」「読んで確認(read)」も作業した側の記録で、P3 は検査を実行していません。要求の根拠(requirementSources)は要望者が残した出典と確認の記録で、確認記録あり(confirmed)も申告です。あなたの判定で確認したことにしないでください。
|
|
95
102
|
- 比較項目ごとに、差分と前後のコードを読み、項目を満たす実装になっているか、抜け・食い違いが無いかを判断してください。
|
|
96
103
|
- 本文には基準に無い要件が書かれていることがあります。見落とさず、基準と本文・基準どうしの矛盾は直さずに checks(人が確かめる点)に書いてください。
|
|
97
104
|
- 意図しない変更: 比較項目・本文のどれにも当たらない変更や、既存の動作を変えてしまう変更を unplanned に挙げてください。commits の otherTasks があるコミットは別のタスクの作業が混ざっている可能性があるので、このタスクの範囲と分けて読んでください。
|
|
@@ -67,12 +67,54 @@ export const AI_MANIFEST = {
|
|
|
67
67
|
desc: "参照先(共有の定義)。GET は読めたかの状態と、ローカルの画面にだけこのマシンのパス。POST {name, role?, readFirst?, writable?, map?, path?}",
|
|
68
68
|
},
|
|
69
69
|
{ method: "PUT|DELETE", path: "/api/repos/:name/path", desc: "参照先のこのマシンのパス(個人設定)。このマシンのローカルの画面(Origin)からだけ" },
|
|
70
|
-
{ method: "GET", path: "/api/requests[?parent=<要望ID>]", desc: "要望の一覧と進捗(更新の新しい順。parent で直下の子だけを親の表示順に)。止まっている自分のタスクの数 blocked と配下の数 subtree.blocked(作業中にも数える)、タスクの印に停止の今の値 block" },
|
|
70
|
+
{ method: "GET", path: "/api/requests[?parent=<要望ID>]", desc: "要望の一覧と進捗(更新の新しい順。parent で直下の子だけを親の表示順に)。止まっている自分のタスクの数 blocked と配下の数 subtree.blocked(作業中にも数える)、タスクの印に停止の今の値 block と証拠の概要 evidence({met, total, declarationOnly, metByBasis, problems}。本文は載せない。基準も証拠も無ければ省く)・完了したタスクの見直しの状態 review、要望ごとの見直し候補の数 review: {self?, tasks, below}(below は自分を除く配下)" },
|
|
71
71
|
{ method: "POST", path: "/api/requests", desc: "要望の作成(parent で子の要望にする。省いた期限・マイルストーン・タグは親から写す)" },
|
|
72
72
|
{
|
|
73
73
|
method: "GET",
|
|
74
74
|
path: "/api/requests/:rid",
|
|
75
|
-
desc: "要望・タスク・Preflight・置き換えられたタスクの印(superseded)・対応済なのに未完了のタスクがあるときの知らせ(issue)・親子(parent・ancestors・children・hierarchyIssues)・対応済にできるか(completion: blocker・見送りで対象外の子 excluded
|
|
75
|
+
desc: "要望・タスク・Preflight・置き換えられたタスクの印(superseded)・対応済なのに未完了のタスクがあるときの知らせ(issue)・親子(parent・ancestors・children・hierarchyIssues)・対応済にできるか(completion: blocker・見送りで対象外の子 excluded)・" +
|
|
76
|
+
"要求の出典と確認(requirement: {state, sources, answers, problems}。state は unrecorded / unconfirmed / confirmed / reconfirm / unlinked。申告の記録で P3 の保証ではない)・" +
|
|
77
|
+
"見直しが必要(候補)(review: {self?(対応済・完了済のときの要望自身の診断), tasks(タスクごとの概要), counts: {tasks, below}})",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
method: "GET|POST",
|
|
81
|
+
path: "/api/requests/:rid/premises",
|
|
82
|
+
desc: "前提の変更(外部の規則の変更など。要望の premiseChanges に追記)。POST {op: \"add\", targets: [要望 ID|タスク ID|要望の根拠の ID], reason, condition, rev?} / {op: \"ack\", id, target, condition, rev?}(変更を確かめたことを残す)。" +
|
|
83
|
+
"基点の完了の記録より後の変更で、確認の無い対象は見直し候補の理由になる。過去の完了の記録・状態・済みは変えない。対象が無い・規則に合わなければ 400 premise_invalid、rev が違えば 409(何も書かない)",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
method: "GET|POST",
|
|
87
|
+
path: "/api/requests/:rid/retrospective[/target]",
|
|
88
|
+
desc: "要望の振り返り。GET は {version, target?(今の対象), targets(確定と訂正の履歴), candidates(採用を終えた run: {run, kind: tasks|split|legacy, latest, basis: [{key?, target, state}], risks}), none?}。" +
|
|
89
|
+
"POST /target {run, reason?, version?} で対象を確定する(候補の run だけ。評価の版とリスクの原文を写す。2回目からの訂正は reason が要る)。候補でない・理由が無い → 400 retro_invalid、版が違う → 409 retro_conflict(何も書かない)。" +
|
|
90
|
+
"GET は今の対象のリスクと確認 risks: [{index, text, state, judgment?, history}]・三状態の件数 counts・全部の確認 judgments・根拠の今の照合 checks(ok|changed|missing|manual)も返す。" +
|
|
91
|
+
"POST /judgments {risk(0 から), state: occurred|not_occurred|unchecked, facts?, scope?, reason?, evidence: [{kind: task_review, task, run, section, index?} | {kind: milestone_review, milestone, run, section, index?, reason?} | {kind: rework, task, history} | {kind: manual, reference, note?}], version?} でリスクの確認を追記する(人の判断。起きた → facts と根拠、起きなかった → scope と根拠、判断を変える → reason。範囲外の根拠は 400)",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
method: "GET",
|
|
95
|
+
path: "/api/metrics[?milestone=<ID>]",
|
|
96
|
+
desc: "開発の指標(p3 metrics と同じ)。範囲は省けばプロジェクト全体(マイルストーンなしを含む)、milestone は登録済みのマイルストーンに直接属する要望(見送り・アーカイブは除く。登録に無い ID は 400 metrics_invalid)。" +
|
|
97
|
+
"{scope, scopeLabel, scopeRule, metrics: [{id, label, kind: record|manual, unit: hours|count|amount, source, target, method, missingRule, recordHint?, state: ok|no_targets|no_data|not_reached|unrecorded, value(ok 以外は null。manual は1行のときだけ), targets, observed, missing, denominator?, breakdown, missingItems, rows?(manual: 範囲が一致する人の記録 {id, from, to, value, unit, source, note?, rev, ...}。合算しない)}], notices(broken_request|manual_unreadable|manual_orphan), scopes}。" +
|
|
98
|
+
"記録の欠けは 0 にせず missing に数える。読むだけ(レビューは実行しない。人の記録を書くのは CLI の p3 metrics record だけ)",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
method: "GET",
|
|
102
|
+
path: "/api/revisit[?request=<要望ID>]",
|
|
103
|
+
desc: "見直しが必要(候補)の一覧(完了したタスクと対応済・完了済の要望。完了済みも含む)。各項目は {target, state, record, qualityVersion, reasons: [{code, target, was?, now?, related?}], unreadable?}。" +
|
|
104
|
+
"品質は作業先に当てはまる項目の差だけを見て、設定全体の版の違い・参照先の HEAD の更新では候補にしない。読むだけでファイルを書かない。タスクの一覧は ?review=true で候補だけに絞れる",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
method: "POST",
|
|
108
|
+
path: "/api/requests/:rid/sources",
|
|
109
|
+
desc: "要求の根拠の記録を変える {ops: [{op:\"add\", target?, source?, basis?, confirm?:{by, on}} | {op:\"edit\", id, target?, source?, basis?, confirm?} | {op:\"confirm\", id, by, on} | {op:\"remove\", id}], rev?}(CLI の p3 source と同じ。結果は {request, requirement})。" +
|
|
110
|
+
"確認には出典・根拠・確かめた人(役割名・アクター名)・YYYY-MM-DD の日が要る。題・本文・記録の内容が変わると確認は再確認が必要になる(元に戻しても戻らない)。" +
|
|
111
|
+
"規則に合わなければ 400 code: requirement_invalid、rev が違えば 409 rev_conflict(どちらも何も書かない)。要望の根拠・回答は評価対象に入る(変えるとその評価からは採用しない)",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
method: "POST",
|
|
115
|
+
path: "/api/requests/:rid/answers",
|
|
116
|
+
desc: "Preflight の確認事項(run の assessment.clarifications)に回答する {run, question, answer(null で消す), by?, on?, source?, basis?, links?: [根拠の記録の ID], rev?}(CLI の p3 answer と同じ)。" +
|
|
117
|
+
"回答は要望の clarifyAnswers に残し、過去の run は書き換えない。回答しただけでは根拠の記録を確認記録ありにしない。再評価は別に明示して始める",
|
|
76
118
|
},
|
|
77
119
|
{
|
|
78
120
|
method: "PATCH",
|
|
@@ -90,8 +132,13 @@ export const AI_MANIFEST = {
|
|
|
90
132
|
},
|
|
91
133
|
{ method: "GET|POST", path: "/api/requests/:rid/tasks", desc: "要望のタスク(GET の ?blocked=true で止まっているものだけ(status・area・q と AND)。POST の criteria: [文] で受け入れ基準を付ける(ID は p3 が振る)。対応済の要望に未完了のタスクを足すと進行中に戻し reopened を返す。対応済の祖先も戻して reopenedAncestors、完了済の祖先は warnings の ancestor_done)" },
|
|
92
134
|
{ method: "GET|PATCH|DELETE", path: "/api/requests/:rid/tasks/:tid", desc: "タスク(GET は置き換えの印 superseded と受け入れ基準の状態 acceptance(不足 shortfalls。基準なしは null)も返す。PATCH は rev で楽観ロック、null で項目を消す。置き換えられたタスクを作業中にすると warnings を添える。" +
|
|
93
|
-
"受け入れ基準・証拠は PATCH の acceptance: [{op: add|edit|remove|order|record|unrecord, ...}]
|
|
135
|
+
"受け入れ基準・証拠は PATCH の acceptance: [{op: add|edit|remove|order|record|unrecord|source, ...}] で順に当て(source は {op:\"source\", id: 基準の ID, source: 要求の根拠への操作}。POST sources と同じ操作で、from で要望の記録を写す)、規則に合わなければ何も書かず 400 code: acceptance_invalid。" +
|
|
136
|
+
"record の basis は根拠 {kind: unverified|declaration} / {kind: read, reference} / {kind: machine, command, result, target}(作業した側の申告。P3 は検査を実行しない)。" +
|
|
137
|
+
"省くと同じ結果の前の証拠の根拠を引き継ぎ、無ければ unverified は未確認・ほかは申告のみ。met / unmet に未確認、unverified にほかの根拠は付けられない。" +
|
|
138
|
+
"acceptance には根拠ごとの met の件数 metByBasis と申告のみの基準 declarationOnly も入る。" +
|
|
94
139
|
"済みのタスクの基準・証拠の中身が変わると済みを外し checkCleared を返す。" +
|
|
140
|
+
"完了・済みにすると、そのときの条件の写しを completionRecords に追記する(要望の PATCH の対応済・完了済も同じ。記録の値は受け付けない。記録が読めず足せなければ completionSkipped)。" +
|
|
141
|
+
"GET は見直しの診断 review(完了したタスクだけ。state: no_record|unreadable|none|candidate、基点の record、reasons: [{code, target, was?, now?, related?}]。状態は変えない)も返す。" +
|
|
95
142
|
"止まっている理由(停止)は PATCH の blockOp: {op: set, reason, decision?}(作業中だけ。内容を直しても since は変えない)/ {op: clear, resolution}(解除。状態は変えない)で変え、" +
|
|
96
143
|
"日時・履歴は受け付けない。規則に合わなければ 400 block_invalid / block_not_doing、止まったまま未着手・完了へ動かすと 409 blocked(解除と移動を同じ PATCH に書けば一緒に保存する))" },
|
|
97
144
|
{
|
|
@@ -141,6 +188,7 @@ export const AI_MANIFEST = {
|
|
|
141
188
|
path: "/api/requests/:rid/preflight/:run/drafts/:key",
|
|
142
189
|
desc: "タスク案を直す {title?, description?, include?, repo?, acceptanceCriteria?, expectedTitle?, expectedCriteria?}。" +
|
|
143
190
|
"acceptanceCriteria は受け入れ基準の並び全体 [{id?, text}](id は残し、無い項目に振る。空で基準なし)で、expectedCriteria(編集を始めたときの基準)が要る。違えば 409 rev_conflict。" +
|
|
191
|
+
"sourceOps: 基準ごとの要求の根拠への操作 [{id: 基準の ID, source: 上の sources と同じ操作(add は from: 要望の記録の ID で写せる)}]。expectedSources(編集を始めたときの acceptanceSources)が要り、違えば 409 rev_conflict。" +
|
|
144
192
|
"expectedTitle(編集を始めたときの題。制御用で案には書かない)を渡すと、" +
|
|
145
193
|
"案のファイルを読み直した今の題と比べ、違えば 409 code: rev_conflict(current に今の案)で書かない。画面から題を変えるときは必ず渡す",
|
|
146
194
|
},
|
package/lib/server/api/routes.js
CHANGED
|
@@ -6,6 +6,13 @@ import { REQUEST_STATUSES, TASK_STATUSES } from "../../shared/types.js";
|
|
|
6
6
|
import { listTasks, progress, resolve } from "../../core/ops.js";
|
|
7
7
|
import { ConflictError, NotFoundError } from "../../core/store/collection.js";
|
|
8
8
|
import { ACCEPTANCE_RESULTS, AcceptanceInputError, acceptanceStatus } from "../../shared/acceptance.js";
|
|
9
|
+
import { requestRequirementView, RequirementInputError } from "../../shared/requirementSource.js";
|
|
10
|
+
import { PremiseInputError } from "../../shared/reviewCandidate.js";
|
|
11
|
+
import { MILESTONE_REVIEW_SECTIONS, RetrospectiveError, RISK_STATES, TASK_REVIEW_SECTIONS } from "../../shared/retrospective.js";
|
|
12
|
+
import { confirmRetrospectiveTarget, judgeRisk, retrospectiveView } from "../../core/retrospective.js";
|
|
13
|
+
import { metricScopeOf, metricsReport } from "../../core/metrics/index.js";
|
|
14
|
+
import { MetricsError } from "../../shared/metrics.js";
|
|
15
|
+
import { requestReview, reviewCandidates, taskReview } from "../../core/reviewCandidates.js";
|
|
9
16
|
import { BlockInputError } from "../../shared/taskBlock.js";
|
|
10
17
|
import { QualityInputError, taskQualityDiff } from "../../shared/quality.js";
|
|
11
18
|
import { qualityTemplate, qualityView, updateQuality } from "../../core/quality.js";
|
|
@@ -25,7 +32,7 @@ import { repoRoutes } from "./repoRoutes.js";
|
|
|
25
32
|
import { releaseNoteRoutes } from "./releaseNoteRoutes.js";
|
|
26
33
|
import { milestoneReviewRoutes } from "./milestoneReviewRoutes.js";
|
|
27
34
|
import { taskReviewRoutes } from "./taskReviewRoutes.js";
|
|
28
|
-
import { archiveTask, checkMilestoneRemoval, createRequest, createTask, orderChildren, updateRequest, updateTask, importQuality } from "../../core/requestOps.js";
|
|
35
|
+
import { archiveTask, checkMilestoneRemoval, createRequest, createTask, orderChildren, updateRequest, updateTask, importQuality, saveClarifyAnswer, updateRequirement, recordPremise } from "../../core/requestOps.js";
|
|
29
36
|
import { PREFLIGHT_RUNNERS } from "../../shared/preflightRunner.js";
|
|
30
37
|
import { StaleInputError } from "../../core/preflight/input.js";
|
|
31
38
|
import { CancelRefusedError, ChildConflictError, ChildDraftsChangedError, DraftConflictError, PulseInputError } from "../../core/preflight/service.js";
|
|
@@ -39,6 +46,7 @@ import { CancelRefusedError, ChildConflictError, ChildDraftsChangedError, DraftC
|
|
|
39
46
|
* /requests/:rid/preflight[/:run] Preflight
|
|
40
47
|
* /requests/:rid/notes Preflight へのメモ
|
|
41
48
|
* /release-notes[/:mid] マイルストーンのリリースノート(releaseNoteRoutes.ts)
|
|
49
|
+
* /metrics[?milestone=<ID>] 開発の指標(core/metrics。読むだけ)
|
|
42
50
|
* /milestones/:mid/review[s...] マイルストーンレビュー(milestoneReviewRoutes.ts)
|
|
43
51
|
* /requests/:rid/tasks/:tid/review[s...] タスクの AI レビュー(taskReviewRoutes.ts)
|
|
44
52
|
*/
|
|
@@ -62,8 +70,11 @@ const acceptanceOp = z.discriminatedUnion("op", [
|
|
|
62
70
|
z.object({ op: z.literal("edit"), id: z.string(), text: z.string() }),
|
|
63
71
|
z.object({ op: z.literal("remove"), id: z.string() }),
|
|
64
72
|
z.object({ op: z.literal("order"), ids: z.array(z.string()) }),
|
|
65
|
-
|
|
73
|
+
// basis(根拠)の形と組み合わせは shared/acceptance.ts の cleanBasis・basisMismatch が確かめる(規則を2か所に書かない)
|
|
74
|
+
z.object({ op: z.literal("record"), id: z.string(), result: z.enum(ACCEPTANCE_RESULTS), evidence: z.string().default(""), basis: z.custom((v) => v !== null && typeof v === "object").optional() }),
|
|
66
75
|
z.object({ op: z.literal("unrecord"), id: z.string() }),
|
|
76
|
+
// 基準ごとの要求の根拠(出典・確認)。操作の形と規則は shared/requirementSource.ts の applySourceOps が確かめる
|
|
77
|
+
z.object({ op: z.literal("source"), id: z.string(), source: z.custom((v) => v !== null && typeof v === "object") }),
|
|
67
78
|
]);
|
|
68
79
|
/** 品質基準の操作(規則は shared/quality.ts。CLI の p3 quality と同じ) */
|
|
69
80
|
const qualityCheck = z.discriminatedUnion("kind", [
|
|
@@ -192,6 +203,18 @@ export function apiRoutes(ctx, opts = {}) {
|
|
|
192
203
|
// 受け入れ基準・証拠の操作が規則に合わない(何も書いていない)
|
|
193
204
|
if (err instanceof AcceptanceInputError)
|
|
194
205
|
return c.json({ error: err.message, code: err.code }, 400);
|
|
206
|
+
// 要求の根拠・回答の操作が規則に合わない(何も書いていない)
|
|
207
|
+
if (err instanceof RequirementInputError)
|
|
208
|
+
return c.json({ error: err.message, code: err.code }, 400);
|
|
209
|
+
// 前提の変更の操作が規則に合わない・対象が無い(何も書いていない)
|
|
210
|
+
if (err instanceof PremiseInputError)
|
|
211
|
+
return c.json({ error: err.message, code: err.code }, 400);
|
|
212
|
+
// 振り返り: 候補でない・理由が無い → 400、版の競合・記録が読めない → 409(何も書いていない)
|
|
213
|
+
if (err instanceof RetrospectiveError)
|
|
214
|
+
return c.json({ error: err.message, code: err.code }, err.code === "retro_invalid" ? 400 : 409);
|
|
215
|
+
// 指標: 知らない範囲(登録されていないマイルストーン)
|
|
216
|
+
if (err instanceof MetricsError)
|
|
217
|
+
return c.json({ error: err.message, code: err.code }, 400);
|
|
195
218
|
// 停止の操作が規則に合わない・止まったままの移動(何も書いていない)
|
|
196
219
|
if (err instanceof BlockInputError)
|
|
197
220
|
return c.json({ error: err.message, code: err.code }, err.code === "blocked" ? 409 : 400);
|
|
@@ -271,6 +294,8 @@ export function apiRoutes(ctx, opts = {}) {
|
|
|
271
294
|
const id = rid(c);
|
|
272
295
|
return c.json({
|
|
273
296
|
request: ws.requests.get(id),
|
|
297
|
+
// 要求の根拠の記録と回答の状態(shared/requirementSource.ts。申告の記録で、P3 の保証ではない)
|
|
298
|
+
requirement: requestRequirementView(ws.requests.require(id)),
|
|
274
299
|
tasks: ws.tasksOf(id).list(),
|
|
275
300
|
runs: await Promise.all((await preflight.list(id)).map((r) => preflight.withInputMatch(id, r))),
|
|
276
301
|
// 対応済なのに未完了のタスクがある(外部の直接編集など)
|
|
@@ -278,6 +303,8 @@ export function apiRoutes(ctx, opts = {}) {
|
|
|
278
303
|
// 親子(parent・ancestors・children・hierarchyIssues)と、対応済にできるか(blocker・見送りで対象外の子 excluded)
|
|
279
304
|
...(await hierarchyView(ws, id)),
|
|
280
305
|
completion: completionCheckOf(ws, hierarchyNow(ws), id),
|
|
306
|
+
// 見直しが必要(候補): 要望自身(対応済・完了済)・タスクごとの概要・配下の件数(読むだけ。shared/reviewCandidate.ts)
|
|
307
|
+
review: requestReview(ctx, id),
|
|
281
308
|
// 置き換えられたタスクの印(T001 → 置き換えた側)
|
|
282
309
|
superseded: Object.fromEntries([...supersededMarks(ws)].filter(([ref]) => ref.startsWith(`${id}/`)).map(([ref, m]) => [ref.slice(id.length + 1), m])),
|
|
283
310
|
});
|
|
@@ -286,6 +313,84 @@ export function apiRoutes(ctx, opts = {}) {
|
|
|
286
313
|
const { rev, ...patch } = requestPatch.parse(await c.req.json());
|
|
287
314
|
return c.json(await updateRequest(ctx, rid(c), unnull(patch), { expectedRev: expectedRev(c, { rev }), actor: actorOf(c) }));
|
|
288
315
|
});
|
|
316
|
+
/** 要望の要求の根拠の記録を変える(CLI の p3 source と同じ操作。順に当て、1つでも合わなければ何も書かない) */
|
|
317
|
+
app.post("/requests/:rid/sources", async (c) => {
|
|
318
|
+
const { ops, rev } = z.object({ ops: z.array(z.custom((v) => v !== null && typeof v === "object")).min(1), rev: z.number().int().optional() }).parse(await c.req.json());
|
|
319
|
+
const r = await updateRequirement(ctx, rid(c), ops, { expectedRev: expectedRev(c, { rev }), actor: actorOf(c) });
|
|
320
|
+
return c.json({ request: r, requirement: requestRequirementView(r) });
|
|
321
|
+
});
|
|
322
|
+
/**
|
|
323
|
+
* Preflight の確認事項に回答する(CLI の p3 answer と同じ)。answer: null で回答を消す。回答は要望に残し、過去の run は書き換えない。
|
|
324
|
+
* 回答しただけでは根拠の記録を確認記録ありにしない。再評価は別に明示して始める
|
|
325
|
+
*/
|
|
326
|
+
/**
|
|
327
|
+
* 前提の変更(外部の規則の変更など)を記録する。add: {op: "add", targets, reason, condition} / ack: {op: "ack", id, target, condition}。
|
|
328
|
+
* 過去の完了の記録・状態・済みは変えない。対象が無い・規則に合わなければ 400 premise_invalid、rev が違えば 409(何も書かない)
|
|
329
|
+
*/
|
|
330
|
+
app.get("/requests/:rid/premises", (c) => c.json(ws.requests.require(rid(c)).premiseChanges ?? []));
|
|
331
|
+
app.post("/requests/:rid/premises", async (c) => {
|
|
332
|
+
const b = z
|
|
333
|
+
.discriminatedUnion("op", [
|
|
334
|
+
z.object({ op: z.literal("add"), targets: z.array(z.string()), reason: z.string(), condition: z.string(), rev: z.number().int().optional() }),
|
|
335
|
+
z.object({ op: z.literal("ack"), id: z.string(), target: z.string(), condition: z.string(), rev: z.number().int().optional() }),
|
|
336
|
+
])
|
|
337
|
+
.parse(await c.req.json());
|
|
338
|
+
const { rev, ...op } = b;
|
|
339
|
+
const r = await recordPremise(ctx, rid(c), op, { expectedRev: expectedRev(c, { rev }), actor: actorOf(c) });
|
|
340
|
+
return c.json({ change: r.change, rev: r.request.rev });
|
|
341
|
+
});
|
|
342
|
+
/** 要望の振り返り: 確定した対象・訂正の履歴・候補(採用を終えた run と根拠)。読むだけ */
|
|
343
|
+
app.get("/requests/:rid/retrospective", async (c) => c.json(await retrospectiveView(ctx, rid(c))));
|
|
344
|
+
/** 振り返りの対象を確定する {run, reason?(2回目からの訂正で必須), version?(読んだときの版)} */
|
|
345
|
+
app.post("/requests/:rid/retrospective/target", async (c) => {
|
|
346
|
+
const b = z.object({ run: z.string().min(1), reason: z.string().optional(), version: z.number().int().optional() }).parse(await c.req.json());
|
|
347
|
+
return c.json(await confirmRetrospectiveTarget(ctx, rid(c), { run: b.run, reason: b.reason }, { expectedVersion: b.version, actor: actorOf(c) }));
|
|
348
|
+
});
|
|
349
|
+
/** リスクの確認を記録する {risk(0 から), state, facts?, scope?, reason?, evidence: [根拠の指定], version?}(人の判断。追記) */
|
|
350
|
+
app.post("/requests/:rid/retrospective/judgments", async (c) => {
|
|
351
|
+
const ev = z.discriminatedUnion("kind", [
|
|
352
|
+
z.object({ kind: z.literal("task_review"), task: z.string(), run: z.string(), section: z.enum(TASK_REVIEW_SECTIONS), index: z.number().int().optional() }),
|
|
353
|
+
z.object({ kind: z.literal("milestone_review"), milestone: z.string(), run: z.string(), section: z.enum(MILESTONE_REVIEW_SECTIONS), index: z.number().int().optional(), reason: z.string().optional() }),
|
|
354
|
+
z.object({ kind: z.literal("rework"), task: z.string(), history: z.string() }),
|
|
355
|
+
z.object({ kind: z.literal("manual"), reference: z.string(), note: z.string().optional() }),
|
|
356
|
+
]);
|
|
357
|
+
const b = z
|
|
358
|
+
.object({ risk: z.number().int().min(0), state: z.enum(RISK_STATES), facts: z.string().optional(), scope: z.string().optional(), reason: z.string().optional(), evidence: z.array(ev).default([]), version: z.number().int().optional() })
|
|
359
|
+
.parse(await c.req.json());
|
|
360
|
+
const { version, ...input } = b;
|
|
361
|
+
return c.json(await judgeRisk(ctx, rid(c), input, { expectedVersion: version, actor: actorOf(c) }));
|
|
362
|
+
});
|
|
363
|
+
/** 見直しが必要(候補)の一覧(完了したタスクと対応済・完了済の要望。完了済みも含む。?request= でその要望だけ) */
|
|
364
|
+
app.get("/metrics", async (c) => c.json(await metricsReport(ctx, metricScopeOf(ctx, c.req.query("milestone")))));
|
|
365
|
+
app.get("/revisit", (c) => {
|
|
366
|
+
const request = c.req.query("request");
|
|
367
|
+
return c.json(reviewCandidates(ctx, request ? { request } : {}));
|
|
368
|
+
});
|
|
369
|
+
app.post("/requests/:rid/answers", async (c) => {
|
|
370
|
+
const b = z
|
|
371
|
+
.object({
|
|
372
|
+
run: z.string(),
|
|
373
|
+
question: z.string(),
|
|
374
|
+
answer: z.string().nullable(),
|
|
375
|
+
by: z.string().optional(),
|
|
376
|
+
on: z.string().optional(),
|
|
377
|
+
source: z.string().optional(),
|
|
378
|
+
basis: z.string().optional(),
|
|
379
|
+
links: z.array(z.string()).optional(),
|
|
380
|
+
rev: z.number().int().optional(),
|
|
381
|
+
})
|
|
382
|
+
.parse(await c.req.json());
|
|
383
|
+
const id = rid(c);
|
|
384
|
+
const run = await preflight.get(id, b.run);
|
|
385
|
+
if (!run)
|
|
386
|
+
throw new NotFoundError(b.run);
|
|
387
|
+
const q = run.assessment?.clarifications?.find((x) => x.id === b.question);
|
|
388
|
+
if (!q)
|
|
389
|
+
return c.json({ error: `${b.run} に確認事項 ${b.question} はありません`, code: "requirement_invalid" }, 400);
|
|
390
|
+
const input = b.answer === null ? null : { answer: b.answer, by: b.by, on: b.on, source: b.source, basis: b.basis, links: b.links };
|
|
391
|
+
const r = await saveClarifyAnswer(ctx, id, b.run, q, input, { expectedRev: expectedRev(c, b), actor: actorOf(c) });
|
|
392
|
+
return c.json({ request: r.request, answer: r.answer ?? null, requirement: requestRequirementView(r.request) });
|
|
393
|
+
});
|
|
289
394
|
/** 子の表示順(直下の子を全部、上から順に。CLI の request order と同じ操作) */
|
|
290
395
|
app.put("/requests/:rid/child-order", async (c) => {
|
|
291
396
|
const { children, rev } = childOrderInput.parse(await c.req.json());
|
|
@@ -324,8 +429,8 @@ export function apiRoutes(ctx, opts = {}) {
|
|
|
324
429
|
});
|
|
325
430
|
// --- tasks(要望の中) --------------------------------------------------------
|
|
326
431
|
app.get("/requests/:rid/tasks", (c) => {
|
|
327
|
-
const { status, area, q, blocked } = c.req.query();
|
|
328
|
-
return c.json(listTasks(ctx, { request: rid(c), status: status?.split(","), area, q, blocked: blocked === "true" }));
|
|
432
|
+
const { status, area, q, blocked, review } = c.req.query();
|
|
433
|
+
return c.json(listTasks(ctx, { request: rid(c), status: status?.split(","), area, q, blocked: blocked === "true", review: review === "true" }));
|
|
329
434
|
});
|
|
330
435
|
app.post("/requests/:rid/tasks", async (c) => {
|
|
331
436
|
const raw = taskCreate.parse(await c.req.json());
|
|
@@ -337,7 +442,7 @@ export function apiRoutes(ctx, opts = {}) {
|
|
|
337
442
|
});
|
|
338
443
|
app.get("/requests/:rid/tasks/:tid", (c) => {
|
|
339
444
|
const task = ws.tasksOf(rid(c)).require(tid(c));
|
|
340
|
-
return c.json({ task, superseded: supersededMarks(ws).get(task.ref) ?? [], acceptance: acceptanceStatus(task) ?? null });
|
|
445
|
+
return c.json({ task, superseded: supersededMarks(ws).get(task.ref) ?? [], acceptance: acceptanceStatus(task) ?? null, review: taskReview(ctx, task) ?? null });
|
|
341
446
|
});
|
|
342
447
|
app.patch("/requests/:rid/tasks/:tid", async (c) => {
|
|
343
448
|
const { rev, checked, acceptance, blockOp: bop, ...patch } = taskPatch.parse(await c.req.json());
|
|
@@ -349,8 +454,17 @@ export function apiRoutes(ctx, opts = {}) {
|
|
|
349
454
|
...(acceptance?.length ? { acceptance } : {}),
|
|
350
455
|
};
|
|
351
456
|
// 置き換えられたタスクを作業中にしたら警告を添える(操作は続ける)。基準・証拠が変わって済みを外したら checkCleared
|
|
352
|
-
|
|
353
|
-
|
|
457
|
+
// 完了の記録が壊れていて足せなかったら completionSkipped(状態は変えた)
|
|
458
|
+
const { task, warnings, reopened, reopenedAncestors, checkCleared, completionSkipped, reworkSkipped } = await updateTask(ctx, rid(c), tid(c), next, { expectedRev: expectedRev(c, { rev }), actor: actorOf(c) });
|
|
459
|
+
return c.json({
|
|
460
|
+
...task,
|
|
461
|
+
...(warnings.length ? { warnings } : {}),
|
|
462
|
+
...(reopened ? { reopened } : {}),
|
|
463
|
+
...(reopenedAncestors ? { reopenedAncestors } : {}),
|
|
464
|
+
...(checkCleared ? { checkCleared } : {}),
|
|
465
|
+
...(completionSkipped ? { completionSkipped } : {}),
|
|
466
|
+
...(reworkSkipped ? { reworkSkipped } : {}),
|
|
467
|
+
});
|
|
354
468
|
});
|
|
355
469
|
/** 今の品質基準との差分(読むだけ。タスクは書き換えない) */
|
|
356
470
|
app.get("/requests/:rid/tasks/:tid/quality-diff", (c) => {
|
|
@@ -497,22 +611,28 @@ export function apiRoutes(ctx, opts = {}) {
|
|
|
497
611
|
// expectedTitle: 編集を始めたときの題(制御用。案には書かない)。今の題と違えば 409 で書かない
|
|
498
612
|
// acceptanceCriteria: 受け入れ基準の並び全体(id は残し、無い項目に振る)。expectedCriteria: 編集を始めたときの基準(違えば 409)
|
|
499
613
|
const criterion = z.object({ id: z.string().nullish(), text: z.string() });
|
|
500
|
-
|
|
614
|
+
// sourceOps: 基準ごとの要求の根拠への操作。expectedSources: 編集を始めたときの根拠の記録(違えば 409。根拠だけの編集の競合も見る)
|
|
615
|
+
const { expectedTitle, expectedCriteria, expectedSources, ...patch } = z
|
|
501
616
|
.object({
|
|
502
617
|
title: z.string(),
|
|
503
618
|
description: z.string(),
|
|
504
619
|
include: z.boolean(),
|
|
505
620
|
repo: z.string().nullable(),
|
|
506
621
|
acceptanceCriteria: z.array(criterion),
|
|
622
|
+
sourceOps: z.array(z.object({ id: z.string(), source: z.custom((v) => v !== null && typeof v === "object") })),
|
|
507
623
|
expectedTitle: z.string(),
|
|
508
624
|
expectedCriteria: z.array(z.object({ id: z.string(), text: z.string() })),
|
|
625
|
+
expectedSources: z.array(z.custom((v) => v !== null && typeof v === "object")),
|
|
509
626
|
})
|
|
510
627
|
.partial()
|
|
511
628
|
.parse(await c.req.json());
|
|
512
629
|
if (patch.acceptanceCriteria !== undefined && expectedCriteria === undefined) {
|
|
513
630
|
return c.json({ error: "受け入れ基準を直すときは expectedCriteria(編集を始めたときの基準)を渡してください", code: "acceptance_invalid" }, 400);
|
|
514
631
|
}
|
|
515
|
-
|
|
632
|
+
if (patch.sourceOps?.length && expectedSources === undefined) {
|
|
633
|
+
return c.json({ error: "要求の根拠を直すときは expectedSources(編集を始めたときの根拠の記録)を渡してください", code: "requirement_invalid" }, 400);
|
|
634
|
+
}
|
|
635
|
+
return c.json(await preflight.updateDraft(rid(c), c.req.param("run"), c.req.param("key"), patch, { expectedTitle, expectedCriteria, expectedSources, actor: actorOf(c) }));
|
|
516
636
|
});
|
|
517
637
|
/** 子の要望の案(分割の run)を直す。expectedTitle は上と同じ */
|
|
518
638
|
app.patch("/requests/:rid/preflight/:run/children/:key", async (c) => {
|
|
@@ -537,8 +657,8 @@ export function apiRoutes(ctx, opts = {}) {
|
|
|
537
657
|
});
|
|
538
658
|
// --- 横断 --------------------------------------------------------------
|
|
539
659
|
app.get("/tasks", (c) => {
|
|
540
|
-
const { status, area, q, blocked } = c.req.query();
|
|
541
|
-
return c.json(listTasks(ctx, { status: status?.split(","), area, q, blocked: blocked === "true" }));
|
|
660
|
+
const { status, area, q, blocked, review } = c.req.query();
|
|
661
|
+
return c.json(listTasks(ctx, { status: status?.split(","), area, q, blocked: blocked === "true", review: review === "true" }));
|
|
542
662
|
});
|
|
543
663
|
/** 参照・タイトルから対象を特定する(?request= で今の要望を優先) */
|
|
544
664
|
app.get("/resolve", (c) => c.json(resolve(ctx, c.req.query("q") ?? "", c.req.query("request"))));
|