peaks-loop 4.1.6 → 4.1.8
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/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +78 -0
- package/config/eslint/tsconfig.lint.json +1 -0
- package/dist/cli/commands/core/skill-registry-commands.js +9 -4
- package/dist/cli/commands/dispatch-from-dag.js +17 -0
- package/dist/cli/commands/job-commands.js +15 -5
- package/dist/cli/commands/lint-baseline-command.d.ts +15 -0
- package/dist/cli/commands/lint-baseline-command.js +64 -0
- package/dist/cli/commands/lint-commands.js +27 -51
- package/dist/cli/commands/request-command-options.d.ts +6 -0
- package/dist/cli/commands/request-commands.js +2 -0
- package/dist/cli/commands/request-mark-qa-initiated-command.d.ts +3 -0
- package/dist/cli/commands/request-mark-qa-initiated-command.js +80 -0
- package/dist/cli/commands/request-transition-failures.js +1 -0
- package/dist/cli/commands/reviewer-commands.d.ts +6 -6
- package/dist/cli/commands/reviewer-commands.js +154 -56
- package/dist/cli/commands/reviewer-config-commands.d.ts +9 -0
- package/dist/cli/commands/reviewer-config-commands.js +133 -0
- package/dist/services/artifacts/artifact-lint-service.js +102 -27
- package/dist/services/artifacts/artifact-prerequisites.d.ts +2 -0
- package/dist/services/artifacts/artifact-prerequisites.js +22 -110
- package/dist/services/artifacts/artifact-template-bodies.d.ts +7 -1
- package/dist/services/artifacts/artifact-template-bodies.js +14 -3
- package/dist/services/artifacts/artifact-templates.d.ts +6 -1
- package/dist/services/artifacts/artifact-templates.js +8 -5
- package/dist/services/artifacts/backcompat-acceptance.d.ts +66 -0
- package/dist/services/artifacts/backcompat-acceptance.js +222 -0
- package/dist/services/artifacts/prerequisite-checks.d.ts +42 -9
- package/dist/services/artifacts/prerequisite-checks.js +35 -11
- package/dist/services/artifacts/prerequisite-path-resolver.d.ts +39 -0
- package/dist/services/artifacts/prerequisite-path-resolver.js +110 -0
- package/dist/services/artifacts/qa-initiated-marker.d.ts +24 -0
- package/dist/services/artifacts/qa-initiated-marker.js +36 -0
- package/dist/services/artifacts/request-artifact-metadata.d.ts +9 -0
- package/dist/services/artifacts/request-artifact-metadata.js +9 -0
- package/dist/services/artifacts/request-artifact-service.js +6 -10
- package/dist/services/artifacts/request-artifact-state-helpers.d.ts +2 -1
- package/dist/services/artifacts/request-artifact-state-helpers.js +6 -3
- package/dist/services/dispatch/isolation-lease.d.ts +3 -2
- package/dist/services/dispatch/isolation-lease.js +15 -6
- package/dist/services/doctor/doctor-service/checks/backcompat-acceptance.d.ts +15 -0
- package/dist/services/doctor/doctor-service/checks/backcompat-acceptance.js +53 -0
- package/dist/services/doctor/doctor-service/checks/skill-reference-parity.d.ts +38 -0
- package/dist/services/doctor/doctor-service/checks/skill-reference-parity.js +243 -0
- package/dist/services/doctor/doctor-service/plugin-registry.js +4 -0
- package/dist/services/doctor/doctor-service/types.d.ts +12 -0
- package/dist/services/job/subagent-job-wrapper.d.ts +20 -7
- package/dist/services/job/subagent-job-wrapper.js +53 -5
- package/dist/services/lint/eslint-report.d.ts +19 -0
- package/dist/services/lint/eslint-report.js +60 -0
- package/dist/services/lint/eslint-runner-support.d.ts +18 -1
- package/dist/services/lint/eslint-runner-support.js +35 -2
- package/dist/services/lint/eslint-runner-types.d.ts +21 -1
- package/dist/services/lint/eslint-runner.js +43 -33
- package/dist/services/prd/gate-evidence-derivation.d.ts +2 -4
- package/dist/services/prd/gate-evidence-derivation.js +3 -1
- package/dist/services/qa/bdd-test-style-contract.d.ts +17 -0
- package/dist/services/qa/bdd-test-style-contract.js +41 -0
- package/dist/services/qa/bdd-test-style-verifier.d.ts +9 -6
- package/dist/services/qa/bdd-test-style-verifier.js +24 -37
- package/dist/services/rd/reviewer-dispatch-policy.d.ts +18 -14
- package/dist/services/rd/reviewer-dispatch-policy.js +14 -11
- package/dist/services/release/release-state.js +20 -5
- package/dist/services/reviewer/model-family.js +1 -1
- package/dist/services/reviewer/reviewer-artifacts.d.ts +12 -0
- package/dist/services/reviewer/reviewer-artifacts.js +67 -0
- package/dist/services/reviewer/reviewer-config-write.d.ts +18 -0
- package/dist/services/reviewer/reviewer-config-write.js +71 -0
- package/dist/services/reviewer/reviewer-config.d.ts +33 -5
- package/dist/services/reviewer/reviewer-config.js +102 -46
- package/dist/services/reviewer/reviewer-envelopes.d.ts +8 -0
- package/dist/services/reviewer/reviewer-envelopes.js +53 -0
- package/dist/services/reviewer/reviewer-service.d.ts +7 -4
- package/dist/services/reviewer/reviewer-service.js +46 -52
- package/dist/services/reviewer/reviewer-types.d.ts +9 -1
- package/dist/services/session/getSessionDir.js +16 -7
- package/dist/services/web/daemon-registry.d.ts +6 -4
- package/dist/services/web/daemon-registry.js +92 -17
- package/dist/services/workflow/pipeline-verify-gate-support.d.ts +4 -1
- package/dist/services/workflow/pipeline-verify-gate-support.js +8 -79
- package/dist/services/workflow/pipeline-verify-rd-phase.d.ts +67 -0
- package/dist/services/workflow/pipeline-verify-rd-phase.js +122 -0
- package/dist/services/workflow/pipeline-verify-service.js +16 -17
- package/dist/services/workspace/workspace-service.js +4 -16
- package/package.json +5 -5
- package/schemas/doctor-report.schema.json +2 -2
- package/schemas/reviewer-envelope.schema.json +1 -1
- package/skills/bee/peaks-reviewer/SKILL.md +20 -4
- package/skills/bee/peaks-reviewer/references/reviewer-schema.md +12 -7
- package/skills/bee/peaks-security-audit/SKILL.md +20 -0
|
@@ -19,29 +19,36 @@ import type { ArtifactPrerequisite } from './artifact-prerequisites.js';
|
|
|
19
19
|
*
|
|
20
20
|
* The stem is what makes the code name WHICH artifact is missing — the branch
|
|
21
21
|
* this replaced emitted the literal `mut-report-missing-deprecated-in-v2.14.0`
|
|
22
|
-
* for EVERY `backCompat` prerequisite, so the `rd/third-party-review
|
|
22
|
+
* for EVERY `backCompat` prerequisite, so the `rd/third-party-review-<rid>.md`
|
|
23
23
|
* warning carried the same code as the `mut/mut-report.json` one and a
|
|
24
24
|
* consumer filtering on it matched both. `backCompatUntil` keeps the
|
|
25
25
|
* deprecation semantics legible and is per-prerequisite, because the two live
|
|
26
26
|
* windows close in different releases (v2.14.0 and v2.15.0).
|
|
27
27
|
*
|
|
28
|
-
* The stem is taken verbatim
|
|
29
|
-
*
|
|
28
|
+
* The stem is taken verbatim from `relativePath`, so no character is rewritten
|
|
29
|
+
* — including a `<rid>` placeholder.
|
|
30
30
|
*
|
|
31
31
|
* TWO KNOWN LIMITS OF THE STEM, stated so neither is read as a guarantee:
|
|
32
32
|
* - a `<rid>`-templated soft prerequisite keeps the placeholder, producing
|
|
33
33
|
* the LITERAL `<rid>-missing-deprecated-in-…` — the same code for every
|
|
34
|
-
* request.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* would have to know to match.
|
|
34
|
+
* request. One live prerequisite now does (`rd/third-party-review-<rid>.md`):
|
|
35
|
+
* its code is filterable by ARTIFACT CLASS but not by slice. That is the
|
|
36
|
+
* deliberate trade — resolving the rid into the code would give every
|
|
37
|
+
* slice a code a consumer would have to already know to match.
|
|
39
38
|
* - the stem comes from the FILENAME only, so two prerequisites sharing a
|
|
40
39
|
* stem collide (`x.md` and `x.json` both yield `x-…`). Measured 0 live
|
|
41
40
|
* collisions, and the pair that exists (`mut/mut-report.json` vs
|
|
42
|
-
* `rd/third-party-review
|
|
41
|
+
* `rd/third-party-review-<rid>.md`) differs by stem as well as by directory.
|
|
43
42
|
*/
|
|
44
43
|
export declare function backCompatWarningCode(prerequisite: ArtifactPrerequisite): string;
|
|
44
|
+
/** Negative when `a` predates `b`, positive when it follows, 0 when their
|
|
45
|
+
* release triples are equal.
|
|
46
|
+
*
|
|
47
|
+
* Exported because the commit-leg expiry gate makes the same comparison the
|
|
48
|
+
* soft warning makes: an acceptance entry is current only while its `reviewBy`
|
|
49
|
+
* is still ahead of the installed release. One comparator, so the two legs
|
|
50
|
+
* cannot disagree about where a window boundary sits. */
|
|
51
|
+
export declare function compareReleaseVersions(a: string, b: string): number;
|
|
45
52
|
/**
|
|
46
53
|
* The soft-pass warning for a missing `prerequisite`, or `null` when a missing
|
|
47
54
|
* file is a HARD failure and belongs in `missing` instead.
|
|
@@ -85,3 +92,29 @@ export declare function prerequisiteBodyViolations(prerequisite: ArtifactPrerequ
|
|
|
85
92
|
* rather than the body).
|
|
86
93
|
*/
|
|
87
94
|
export declare function bodyViolationsIfDeclared(prerequisite: ArtifactPrerequisite, read: () => Promise<string>): Promise<string[]>;
|
|
95
|
+
/**
|
|
96
|
+
* One unmet prerequisite as `checkPrerequisites` reports it. `path` and
|
|
97
|
+
* `description` are unchanged from the pre-`kind` shape so every existing
|
|
98
|
+
* consumer keeps reading them; `kind` is the machine-readable answer to "is the
|
|
99
|
+
* file absent, or present and failing its body contract?" — the question a
|
|
100
|
+
* consumer previously had to infer by parsing the prose.
|
|
101
|
+
*
|
|
102
|
+
* - `absent`: nothing resolved at `path`.
|
|
103
|
+
* - `body`: a file resolved and failed the body markers its prerequisite
|
|
104
|
+
* declares.
|
|
105
|
+
*/
|
|
106
|
+
export type UnmetPrerequisite = {
|
|
107
|
+
path: string;
|
|
108
|
+
description: string;
|
|
109
|
+
kind: 'absent' | 'body';
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* The transition refusal's message line: the total plus the split a reader
|
|
113
|
+
* needs to tell "you have not written it" from "you wrote it and it does not
|
|
114
|
+
* satisfy the contract". A bare total sent a producer to produce a file that
|
|
115
|
+
* already existed.
|
|
116
|
+
*
|
|
117
|
+
* A zero count is omitted, so the line never reads
|
|
118
|
+
* `…: 0 missing artifacts, 1 present but invalid`.
|
|
119
|
+
*/
|
|
120
|
+
export declare function unmetPrerequisiteMessage(role: string, newState: string, sessionId: string, missing: ReadonlyArray<Pick<UnmetPrerequisite, 'kind'>>): string;
|
|
@@ -26,27 +26,26 @@ const UNDECLARED_WINDOW = 'a-future-release';
|
|
|
26
26
|
*
|
|
27
27
|
* The stem is what makes the code name WHICH artifact is missing — the branch
|
|
28
28
|
* this replaced emitted the literal `mut-report-missing-deprecated-in-v2.14.0`
|
|
29
|
-
* for EVERY `backCompat` prerequisite, so the `rd/third-party-review
|
|
29
|
+
* for EVERY `backCompat` prerequisite, so the `rd/third-party-review-<rid>.md`
|
|
30
30
|
* warning carried the same code as the `mut/mut-report.json` one and a
|
|
31
31
|
* consumer filtering on it matched both. `backCompatUntil` keeps the
|
|
32
32
|
* deprecation semantics legible and is per-prerequisite, because the two live
|
|
33
33
|
* windows close in different releases (v2.14.0 and v2.15.0).
|
|
34
34
|
*
|
|
35
|
-
* The stem is taken verbatim
|
|
36
|
-
*
|
|
35
|
+
* The stem is taken verbatim from `relativePath`, so no character is rewritten
|
|
36
|
+
* — including a `<rid>` placeholder.
|
|
37
37
|
*
|
|
38
38
|
* TWO KNOWN LIMITS OF THE STEM, stated so neither is read as a guarantee:
|
|
39
39
|
* - a `<rid>`-templated soft prerequisite keeps the placeholder, producing
|
|
40
40
|
* the LITERAL `<rid>-missing-deprecated-in-…` — the same code for every
|
|
41
|
-
* request.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* would have to know to match.
|
|
41
|
+
* request. One live prerequisite now does (`rd/third-party-review-<rid>.md`):
|
|
42
|
+
* its code is filterable by ARTIFACT CLASS but not by slice. That is the
|
|
43
|
+
* deliberate trade — resolving the rid into the code would give every
|
|
44
|
+
* slice a code a consumer would have to already know to match.
|
|
46
45
|
* - the stem comes from the FILENAME only, so two prerequisites sharing a
|
|
47
46
|
* stem collide (`x.md` and `x.json` both yield `x-…`). Measured 0 live
|
|
48
47
|
* collisions, and the pair that exists (`mut/mut-report.json` vs
|
|
49
|
-
* `rd/third-party-review
|
|
48
|
+
* `rd/third-party-review-<rid>.md`) differs by stem as well as by directory.
|
|
50
49
|
*/
|
|
51
50
|
export function backCompatWarningCode(prerequisite) {
|
|
52
51
|
const stem = basename(prerequisite.relativePath, extname(prerequisite.relativePath));
|
|
@@ -73,8 +72,13 @@ function releaseTriple(version) {
|
|
|
73
72
|
return triple;
|
|
74
73
|
}
|
|
75
74
|
/** Negative when `a` predates `b`, positive when it follows, 0 when their
|
|
76
|
-
* release triples are equal.
|
|
77
|
-
|
|
75
|
+
* release triples are equal.
|
|
76
|
+
*
|
|
77
|
+
* Exported because the commit-leg expiry gate makes the same comparison the
|
|
78
|
+
* soft warning makes: an acceptance entry is current only while its `reviewBy`
|
|
79
|
+
* is still ahead of the installed release. One comparator, so the two legs
|
|
80
|
+
* cannot disagree about where a window boundary sits. */
|
|
81
|
+
export function compareReleaseVersions(a, b) {
|
|
78
82
|
const left = releaseTriple(a);
|
|
79
83
|
const right = releaseTriple(b);
|
|
80
84
|
for (let index = 0; index < RELEASE_SEGMENTS; index += 1) {
|
|
@@ -196,3 +200,23 @@ export async function bodyViolationsIfDeclared(prerequisite, read) {
|
|
|
196
200
|
return [];
|
|
197
201
|
return prerequisiteBodyViolations(prerequisite, await read());
|
|
198
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* The transition refusal's message line: the total plus the split a reader
|
|
205
|
+
* needs to tell "you have not written it" from "you wrote it and it does not
|
|
206
|
+
* satisfy the contract". A bare total sent a producer to produce a file that
|
|
207
|
+
* already existed.
|
|
208
|
+
*
|
|
209
|
+
* A zero count is omitted, so the line never reads
|
|
210
|
+
* `…: 0 missing artifacts, 1 present but invalid`.
|
|
211
|
+
*/
|
|
212
|
+
export function unmetPrerequisiteMessage(role, newState, sessionId, missing) {
|
|
213
|
+
const absent = missing.filter((entry) => entry.kind === 'absent').length;
|
|
214
|
+
const invalid = missing.length - absent;
|
|
215
|
+
const counts = [
|
|
216
|
+
...(absent === 0 ? [] : [`${absent} missing artifact${absent === 1 ? '' : 's'}`]),
|
|
217
|
+
...(invalid === 0 ? [] : [`${invalid} present but invalid`])
|
|
218
|
+
].join(', ');
|
|
219
|
+
const total = missing.length;
|
|
220
|
+
return (`Cannot transition ${role} to ${newState}: ${total} unmet requirement${total === 1 ? '' : 's'}` +
|
|
221
|
+
`${counts === '' ? '' : `: ${counts}`} under .peaks/_runtime/${sessionId}/`);
|
|
222
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a prerequisite resolves on disk: its declared path, the numbered
|
|
3
|
+
* filename prefix `request init` writes, and the historical session-root tiers.
|
|
4
|
+
*
|
|
5
|
+
* THE ONE RESOLVER. The transition (`checkPrerequisites`) and the commit gate
|
|
6
|
+
* (`checkExpiredBackCompatCommitGate`) both ask this module, so a numbered
|
|
7
|
+
* prefix or a legacy root that one honours cannot be misread by the other.
|
|
8
|
+
* It lives here, rather than in `artifact-prerequisites.ts`, because that file
|
|
9
|
+
* is over the file-size cap and a change may only shrink it.
|
|
10
|
+
*/
|
|
11
|
+
import type { ArtifactPrerequisite } from './artifact-prerequisites.js';
|
|
12
|
+
export declare function resolvePrerequisitePath(prerequisite: ArtifactPrerequisite, requestId: string): string;
|
|
13
|
+
/** The two session-root tiers the resolver probes: the canonical session home
|
|
14
|
+
* and the pre-F3 legacy one. ONE constructor, so the transition and the commit
|
|
15
|
+
* gate cannot disagree about where a session's evidence lives. */
|
|
16
|
+
export type SessionRoots = {
|
|
17
|
+
canonical: string | null;
|
|
18
|
+
legacy: string | null;
|
|
19
|
+
};
|
|
20
|
+
export declare function sessionRootsFor(projectRoot: string, sessionId: string | undefined): SessionRoots;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve a prerequisite to an on-disk path, with a 2-tier fallback
|
|
23
|
+
* dirs are no longer created):
|
|
24
|
+
* 1. `<canonicalSessionRoot>/<relative>` (post-F3 canonical session
|
|
25
|
+
* home, when `canonicalSessionRoot` is provided).
|
|
26
|
+
* 2. `<legacySessionRoot>/<relative>` (pre-F3 legacy session home,
|
|
27
|
+
* when `legacySessionRoot` is provided).
|
|
28
|
+
* Tolerates the numbered filename prefix that `request init` writes
|
|
29
|
+
* (e.g. `001-<rid>.md`) at every tier. Returns the matched absolute
|
|
30
|
+
* path, or null when nothing matches.
|
|
31
|
+
*
|
|
32
|
+
* Back-compat: once neither primary session-root tier resolved, the
|
|
33
|
+
* resolver walks `prerequisite.legacyRelativePaths` in declared order
|
|
34
|
+
* and tries each at BOTH session roots before declaring the prereq
|
|
35
|
+
* missing. This covers both artifacts that moved location
|
|
36
|
+
* (`rd/security-review.md` → `audit/security.md`) and ones that later
|
|
37
|
+
* gained a rid in the filename (`audit/security.md` →
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolvePrerequisiteAbsolutePathWithFallback(canonicalSessionRoot: string | null, legacySessionRoot: string | null, prerequisite: ArtifactPrerequisite, requestId: string): Promise<string | null>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a prerequisite resolves on disk: its declared path, the numbered
|
|
3
|
+
* filename prefix `request init` writes, and the historical session-root tiers.
|
|
4
|
+
*
|
|
5
|
+
* THE ONE RESOLVER. The transition (`checkPrerequisites`) and the commit gate
|
|
6
|
+
* (`checkExpiredBackCompatCommitGate`) both ask this module, so a numbered
|
|
7
|
+
* prefix or a legacy root that one honours cannot be misread by the other.
|
|
8
|
+
* It lives here, rather than in `artifact-prerequisites.ts`, because that file
|
|
9
|
+
* is over the file-size cap and a change may only shrink it.
|
|
10
|
+
*/
|
|
11
|
+
import { join, dirname, basename } from 'node:path';
|
|
12
|
+
import { readdir } from 'node:fs/promises';
|
|
13
|
+
import { pathExists } from 'peaks-loop-shared/fs';
|
|
14
|
+
import { NUMBERED_PREFIX_RE, slugifyDescription } from '../../shared/incrementing-number.js';
|
|
15
|
+
export function resolvePrerequisitePath(prerequisite, requestId) {
|
|
16
|
+
return prerequisite.relativePath.replace('<rid>', requestId);
|
|
17
|
+
}
|
|
18
|
+
export function sessionRootsFor(projectRoot, sessionId) {
|
|
19
|
+
if (sessionId === undefined)
|
|
20
|
+
return { canonical: null, legacy: null };
|
|
21
|
+
return {
|
|
22
|
+
canonical: join(projectRoot, '.peaks', '_runtime', sessionId),
|
|
23
|
+
legacy: join(projectRoot, '.peaks', sessionId)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolve a prerequisite to an on-disk path, tolerating the numbered filename
|
|
28
|
+
* prefix that `request init` writes (e.g. `001-<rid>.md`). When the prerequisite
|
|
29
|
+
* path contains `<rid>`, we accept either the legacy bare `<rid>.md` form or any
|
|
30
|
+
* `NNN-<rid>.md` numbered form — mirroring the matcher in request-artifact-service.
|
|
31
|
+
* Returns the matched absolute path, or null when nothing matches.
|
|
32
|
+
*/
|
|
33
|
+
async function resolvePrerequisiteAbsolutePath(sessionRoot, prerequisite, requestId) {
|
|
34
|
+
const relative = resolvePrerequisitePath(prerequisite, requestId);
|
|
35
|
+
const exact = join(sessionRoot, relative);
|
|
36
|
+
if (await pathExists(exact)) {
|
|
37
|
+
return exact;
|
|
38
|
+
}
|
|
39
|
+
// Only `<rid>`-templated prerequisites can carry a numbered prefix; fixed paths
|
|
40
|
+
// (e.g. rd/tech-doc.md) are matched exactly above.
|
|
41
|
+
if (!prerequisite.relativePath.includes('<rid>')) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const dir = dirname(exact);
|
|
45
|
+
// The on-disk suffix is the SLUG of this basename — the writer lowercases the
|
|
46
|
+
// rid — so a mixed-case rid used to be reported absent with the file on disk.
|
|
47
|
+
const suffix = `-${slugifyDescription(basename(exact).replace(/\.md$/, ''))}.md`;
|
|
48
|
+
let entries;
|
|
49
|
+
try {
|
|
50
|
+
entries = await readdir(dir);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// TODO(g2): legacy silent catch — grace: 1 minor release (v2.14.0)
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const match = entries.find((name) => NUMBERED_PREFIX_RE.test(name) && name.endsWith(suffix));
|
|
57
|
+
return match ? join(dir, match) : null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolve a prerequisite to an on-disk path, with a 2-tier fallback
|
|
61
|
+
* dirs are no longer created):
|
|
62
|
+
* 1. `<canonicalSessionRoot>/<relative>` (post-F3 canonical session
|
|
63
|
+
* home, when `canonicalSessionRoot` is provided).
|
|
64
|
+
* 2. `<legacySessionRoot>/<relative>` (pre-F3 legacy session home,
|
|
65
|
+
* when `legacySessionRoot` is provided).
|
|
66
|
+
* Tolerates the numbered filename prefix that `request init` writes
|
|
67
|
+
* (e.g. `001-<rid>.md`) at every tier. Returns the matched absolute
|
|
68
|
+
* path, or null when nothing matches.
|
|
69
|
+
*
|
|
70
|
+
* Back-compat: once neither primary session-root tier resolved, the
|
|
71
|
+
* resolver walks `prerequisite.legacyRelativePaths` in declared order
|
|
72
|
+
* and tries each at BOTH session roots before declaring the prereq
|
|
73
|
+
* missing. This covers both artifacts that moved location
|
|
74
|
+
* (`rd/security-review.md` → `audit/security.md`) and ones that later
|
|
75
|
+
* gained a rid in the filename (`audit/security.md` →
|
|
76
|
+
*/
|
|
77
|
+
export async function resolvePrerequisiteAbsolutePathWithFallback(canonicalSessionRoot, legacySessionRoot, prerequisite, requestId) {
|
|
78
|
+
const roots = [canonicalSessionRoot, legacySessionRoot];
|
|
79
|
+
// First pass: try the primary relativePath at every root.
|
|
80
|
+
for (const root of roots) {
|
|
81
|
+
if (root === null)
|
|
82
|
+
continue;
|
|
83
|
+
const found = await resolvePrerequisiteAbsolutePath(root, prerequisite, requestId);
|
|
84
|
+
if (found !== null)
|
|
85
|
+
return found;
|
|
86
|
+
}
|
|
87
|
+
// Second pass: the single previous location, then any further older
|
|
88
|
+
// ones, at every root — newest first, so a session that somehow holds
|
|
89
|
+
// both a pre-rid and a v2.11.x file resolves to the newer shape.
|
|
90
|
+
// Only the relativePath is swapped — the same numbered-prefix
|
|
91
|
+
// tolerance applies via the shared resolver.
|
|
92
|
+
const legacyTiers = [
|
|
93
|
+
...(prerequisite.legacyRelativePath !== undefined ? [prerequisite.legacyRelativePath] : []),
|
|
94
|
+
...(prerequisite.legacyRelativePaths ?? [])
|
|
95
|
+
];
|
|
96
|
+
for (const legacy of legacyTiers) {
|
|
97
|
+
const legacyPrereq = {
|
|
98
|
+
...prerequisite,
|
|
99
|
+
relativePath: legacy
|
|
100
|
+
};
|
|
101
|
+
for (const root of roots) {
|
|
102
|
+
if (root === null)
|
|
103
|
+
continue;
|
|
104
|
+
const found = await resolvePrerequisiteAbsolutePath(root, legacyPrereq, requestId);
|
|
105
|
+
if (found !== null)
|
|
106
|
+
return found;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type MarkQaInitiatedOptions = {
|
|
2
|
+
projectRoot: string;
|
|
3
|
+
sessionId: string;
|
|
4
|
+
};
|
|
5
|
+
export type MarkQaInitiatedResult = {
|
|
6
|
+
/** Absolute path of the marker. */
|
|
7
|
+
path: string;
|
|
8
|
+
/** `true` only on the call that created the file; `false` when it already existed. */
|
|
9
|
+
created: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Create `.peaks/_runtime/<sessionId>/qa/.initiated` if it is absent.
|
|
13
|
+
*
|
|
14
|
+
* Idempotent by construction: the create is a single `O_EXCL` write (`flag:
|
|
15
|
+
* 'wx'`), so an existing marker — including one carrying bytes — is never
|
|
16
|
+
* truncated, and a concurrent caller sees `EEXIST` rather than a second write.
|
|
17
|
+
* The marker's content is the empty string, matching the shape `request init`
|
|
18
|
+
* has always produced.
|
|
19
|
+
*
|
|
20
|
+
* This function touches nothing under `qa/requests/`: the request artifact is
|
|
21
|
+
* the caller's, and this verb exists so it never has to be deleted or rewritten
|
|
22
|
+
* to reach the marker.
|
|
23
|
+
*/
|
|
24
|
+
export declare function markQaInitiated(options: MarkQaInitiatedOptions): Promise<MarkQaInitiatedResult>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The session-scoped `qa/.initiated` marker, written from two callers:
|
|
2
|
+
// `createRequestArtifact` (its success path, after the request file is on disk)
|
|
3
|
+
// and `peaks request mark-qa-initiated` (the in-order path for a QA role that
|
|
4
|
+
// wrote its artifact first). Keeping one writer means the two paths cannot
|
|
5
|
+
// drift on content, permissions, or idempotence.
|
|
6
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { guardRuntimeSegment, runtimeRoot } from '../../shared/runtime-root.js';
|
|
9
|
+
/**
|
|
10
|
+
* Create `.peaks/_runtime/<sessionId>/qa/.initiated` if it is absent.
|
|
11
|
+
*
|
|
12
|
+
* Idempotent by construction: the create is a single `O_EXCL` write (`flag:
|
|
13
|
+
* 'wx'`), so an existing marker — including one carrying bytes — is never
|
|
14
|
+
* truncated, and a concurrent caller sees `EEXIST` rather than a second write.
|
|
15
|
+
* The marker's content is the empty string, matching the shape `request init`
|
|
16
|
+
* has always produced.
|
|
17
|
+
*
|
|
18
|
+
* This function touches nothing under `qa/requests/`: the request artifact is
|
|
19
|
+
* the caller's, and this verb exists so it never has to be deleted or rewritten
|
|
20
|
+
* to reach the marker.
|
|
21
|
+
*/
|
|
22
|
+
export async function markQaInitiated(options) {
|
|
23
|
+
const qaDir = runtimeRoot(options.projectRoot).join(guardRuntimeSegment(options.sessionId, 'session id'), guardRuntimeSegment('qa', 'role'));
|
|
24
|
+
const path = join(qaDir, '.initiated');
|
|
25
|
+
await mkdir(qaDir, { recursive: true });
|
|
26
|
+
try {
|
|
27
|
+
await writeFile(path, '', { encoding: 'utf8', flag: 'wx' });
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (error.code === 'EEXIST') {
|
|
31
|
+
return { path, created: false };
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
return { path, created: true };
|
|
36
|
+
}
|
|
@@ -27,5 +27,14 @@ export type ArtifactMetadata = {
|
|
|
27
27
|
* `request-artifact-service.ts` when the type's provenance was added; the only
|
|
28
28
|
* behaviour change is `requestTypeSource`, which records whether a usable
|
|
29
29
|
* `- type:` line was actually present.
|
|
30
|
+
*
|
|
31
|
+
* THIS READER IS THE CANONICAL `- type:` RULE. `.husky/pipeline/request-type-line.mjs`
|
|
32
|
+
* reimplements it because that module must load under bare `node` and cannot import
|
|
33
|
+
* `src/**`, and `tests/unit/hooks/pipeline-verify-type-derivation.test.ts` drives
|
|
34
|
+
* both readers over one corpus so they cannot drift. The rule: each line is
|
|
35
|
+
* trimmed, the bullet is a hyphen, the value is everything after `type:` and must
|
|
36
|
+
* be a request type (`isRequestType`), and the LAST usable line wins — an unusable
|
|
37
|
+
* later line does not erase an earlier usable one, and no usable line leaves the
|
|
38
|
+
* default with source `default`.
|
|
30
39
|
*/
|
|
31
40
|
export declare function extractMetadata(markdown: string): ArtifactMetadata;
|
|
@@ -5,6 +5,15 @@ import { readArtifactState } from './request-artifact-state-helpers.js';
|
|
|
5
5
|
* `request-artifact-service.ts` when the type's provenance was added; the only
|
|
6
6
|
* behaviour change is `requestTypeSource`, which records whether a usable
|
|
7
7
|
* `- type:` line was actually present.
|
|
8
|
+
*
|
|
9
|
+
* THIS READER IS THE CANONICAL `- type:` RULE. `.husky/pipeline/request-type-line.mjs`
|
|
10
|
+
* reimplements it because that module must load under bare `node` and cannot import
|
|
11
|
+
* `src/**`, and `tests/unit/hooks/pipeline-verify-type-derivation.test.ts` drives
|
|
12
|
+
* both readers over one corpus so they cannot drift. The rule: each line is
|
|
13
|
+
* trimmed, the bullet is a hyphen, the value is everything after `type:` and must
|
|
14
|
+
* be a request type (`isRequestType`), and the LAST usable line wins — an unusable
|
|
15
|
+
* later line does not erase an earlier usable one, and no usable line leaves the
|
|
16
|
+
* default with source `default`.
|
|
8
17
|
*/
|
|
9
18
|
export function extractMetadata(markdown) {
|
|
10
19
|
const state = readArtifactState(markdown) ?? 'unknown';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mkdir, readFile, readdir, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
2
|
import { dirname, join } from 'node:path';
|
|
4
3
|
import { isDirectory, listDirectories } from 'peaks-loop-shared/fs';
|
|
5
4
|
import { checkPrerequisites, DEFAULT_REQUEST_TYPE, isRequestType, VALID_REQUEST_TYPES } from './artifact-prerequisites.js';
|
|
5
|
+
import { markQaInitiated } from './qa-initiated-marker.js';
|
|
6
6
|
import { ensureSession, getSessionIdCanonical } from '../session/session-manager.js';
|
|
7
7
|
// removed with the change-id axis. The change-id binding file is
|
|
8
8
|
// gone; request-artifact callers pass `options.sessionId` explicitly
|
|
@@ -147,7 +147,7 @@ export async function createRequestArtifact(options) {
|
|
|
147
147
|
const content = renderTemplate(options.role, options.requestId, sessionId, sessionSlug, timestamp,
|
|
148
148
|
// `null`, not the default: an untyped request records no type, so the
|
|
149
149
|
// reader's substitution stays visible as a substitution.
|
|
150
|
-
options.requestType ?? null);
|
|
150
|
+
{ requestType: options.requestType ?? null, projectRoot: options.projectRoot });
|
|
151
151
|
if (options.apply !== true) {
|
|
152
152
|
// session-axis dir (`.peaks/_runtime/<sid>/`). Pre-resolved here
|
|
153
153
|
// so dry-run output reports the canonical scope location.
|
|
@@ -166,14 +166,10 @@ export async function createRequestArtifact(options) {
|
|
|
166
166
|
await mkdir(dirname(path), { recursive: true });
|
|
167
167
|
await writeFile(path, content, 'utf8');
|
|
168
168
|
// Create QA initiated marker so rd:qa-handoff gate can verify QA was invoked.
|
|
169
|
-
// The
|
|
169
|
+
// The writer is shared with `peaks request mark-qa-initiated`, the in-order
|
|
170
|
+
// path for a QA role that wrote its artifact before this command ran.
|
|
170
171
|
if (options.role === 'qa') {
|
|
171
|
-
|
|
172
|
-
const initiatedPath = join(qaDir, '.initiated');
|
|
173
|
-
if (!existsSync(initiatedPath)) {
|
|
174
|
-
await mkdir(qaDir, { recursive: true });
|
|
175
|
-
await writeFile(initiatedPath, '', 'utf8');
|
|
176
|
-
}
|
|
172
|
+
await markQaInitiated({ projectRoot: options.projectRoot, sessionId });
|
|
177
173
|
}
|
|
178
174
|
return {
|
|
179
175
|
role: options.role,
|
|
@@ -403,7 +399,7 @@ export async function transitionRequestArtifact(options) {
|
|
|
403
399
|
if (lintReport !== null && !lintReport.ok) {
|
|
404
400
|
const errors = lintReport.findings.filter((f) => f.severity === 'error');
|
|
405
401
|
if (errors.length > 0) {
|
|
406
|
-
throw new LintGateError(options.role, options.newState, errors);
|
|
402
|
+
throw new LintGateError(options.role, options.newState, errors, lintReport.path);
|
|
407
403
|
}
|
|
408
404
|
}
|
|
409
405
|
}
|
|
@@ -31,7 +31,8 @@ export declare class LintGateError extends Error {
|
|
|
31
31
|
readonly newState: RequestArtifactState;
|
|
32
32
|
readonly errorCount: number;
|
|
33
33
|
readonly findings: ReadonlyArray<LintGateFinding>;
|
|
34
|
-
|
|
34
|
+
readonly path: string;
|
|
35
|
+
constructor(role: RequestArtifactRole, newState: RequestArtifactState, findings: ReadonlyArray<LintGateFinding>, path: string);
|
|
35
36
|
}
|
|
36
37
|
export declare class TypeSanityViolationError extends Error {
|
|
37
38
|
readonly code = "TYPE_SANITY_VIOLATION";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unmetPrerequisiteMessage } from './prerequisite-checks.js';
|
|
1
2
|
export const ALLOWED_STATES_PER_ROLE = {
|
|
2
3
|
prd: ['draft', 'confirmed-by-user', 'handed-off', 'blocked'],
|
|
3
4
|
ui: ['draft', 'direction-locked', 'handed-off', 'blocked'],
|
|
@@ -22,7 +23,7 @@ export class PrerequisitesNotSatisfiedError extends Error {
|
|
|
22
23
|
*/
|
|
23
24
|
warnings;
|
|
24
25
|
constructor(role, newState, sessionId, missing, warnings = []) {
|
|
25
|
-
super(
|
|
26
|
+
super(unmetPrerequisiteMessage(role, newState, sessionId, missing));
|
|
26
27
|
this.name = 'PrerequisitesNotSatisfiedError';
|
|
27
28
|
this.role = role;
|
|
28
29
|
this.newState = newState;
|
|
@@ -37,14 +38,16 @@ export class LintGateError extends Error {
|
|
|
37
38
|
newState;
|
|
38
39
|
errorCount;
|
|
39
40
|
findings;
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
path;
|
|
42
|
+
constructor(role, newState, findings, path) {
|
|
43
|
+
super(`Cannot transition ${role} to ${newState}: ${findings.length} lint error(s) found in ${path}. ` +
|
|
42
44
|
'Fix lint errors or use --allow-incomplete to bypass.');
|
|
43
45
|
this.name = 'LintGateError';
|
|
44
46
|
this.role = role;
|
|
45
47
|
this.newState = newState;
|
|
46
48
|
this.findings = findings;
|
|
47
49
|
this.errorCount = findings.length;
|
|
50
|
+
this.path = path;
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
export class TypeSanityViolationError extends Error {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spawn as childProcessSpawn } from 'node:child_process';
|
|
1
2
|
/**
|
|
2
3
|
* lease by shelling out to `peaks worktree spawn` (avoid re-implementing
|
|
3
4
|
* the lease-write + git-worktree-add sequence in this file). The CLI
|
|
@@ -15,7 +16,7 @@ export declare function spawnWorktreeLease(args: {
|
|
|
15
16
|
rid: string;
|
|
16
17
|
role: string;
|
|
17
18
|
purpose: string;
|
|
18
|
-
}): Promise<{
|
|
19
|
+
}, spawnImplOverride?: typeof childProcessSpawn): Promise<{
|
|
19
20
|
leaseId: string;
|
|
20
21
|
path: string;
|
|
21
22
|
branch: string;
|
|
@@ -36,6 +37,6 @@ export declare function spawnContainerLease(args: {
|
|
|
36
37
|
rid: string;
|
|
37
38
|
role: string;
|
|
38
39
|
purpose: string;
|
|
39
|
-
}): Promise<{
|
|
40
|
+
}, spawnImplOverride?: typeof childProcessSpawn): Promise<{
|
|
40
41
|
leaseId: string;
|
|
41
42
|
}>;
|
|
@@ -10,9 +10,11 @@ import { spawn as childProcessSpawn } from 'node:child_process';
|
|
|
10
10
|
* dispatch is already async, the lease is a few hundred ms of FS work,
|
|
11
11
|
* and we need the leaseId before we build the dispatch record.
|
|
12
12
|
*/
|
|
13
|
-
export function spawnWorktreeLease(args) {
|
|
13
|
+
export function spawnWorktreeLease(args, spawnImplOverride = childProcessSpawn) {
|
|
14
|
+
// A same-file alias, not the parameter, is what the spawn guard resolves.
|
|
15
|
+
const spawnImpl = spawnImplOverride ?? childProcessSpawn;
|
|
14
16
|
return new Promise((resolve, reject) => {
|
|
15
|
-
const child =
|
|
17
|
+
const child = spawnImpl(process.execPath, [
|
|
16
18
|
// The compiled CLI lives in dist/cli/peaks.js. We pass the entry
|
|
17
19
|
// through node so the test suite (which also runs on the same
|
|
18
20
|
// process) and the production binary share the same path. When
|
|
@@ -92,9 +94,11 @@ export function spawnWorktreeLease(args) {
|
|
|
92
94
|
* path because the envelope surfaces a different set of
|
|
93
95
|
* fields (image + containerId; see container-lease.ts).
|
|
94
96
|
*/
|
|
95
|
-
export function spawnContainerLease(args) {
|
|
97
|
+
export function spawnContainerLease(args, spawnImplOverride = childProcessSpawn) {
|
|
98
|
+
// A same-file alias, not the parameter, is what the spawn guard resolves.
|
|
99
|
+
const spawnImpl = spawnImplOverride ?? childProcessSpawn;
|
|
96
100
|
return new Promise((resolve, reject) => {
|
|
97
|
-
const child =
|
|
101
|
+
const child = spawnImpl(process.execPath, [
|
|
98
102
|
process.argv[1] ?? '',
|
|
99
103
|
'container',
|
|
100
104
|
'spawn',
|
|
@@ -142,8 +146,13 @@ export function spawnContainerLease(args) {
|
|
|
142
146
|
return;
|
|
143
147
|
}
|
|
144
148
|
resolve({ leaseId: env.data.lease.leaseId });
|
|
149
|
+
// Same deferral as spawnWorktreeLease: the unref must not run
|
|
150
|
+
// before the close, or the parent's event loop empties before
|
|
151
|
+
// the buffered stdout drains and the caller sees an empty
|
|
152
|
+
// envelope with exit 0.
|
|
153
|
+
setImmediate(() => {
|
|
154
|
+
child.unref();
|
|
155
|
+
});
|
|
145
156
|
});
|
|
146
|
-
// See spawnWorktreeLease above for the rationale.
|
|
147
|
-
child.unref();
|
|
148
157
|
});
|
|
149
158
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check: the project carries the commit-leg back-compat acceptance list
|
|
3
|
+
* (`config:backcompat-acceptance`).
|
|
4
|
+
*
|
|
5
|
+
* Absence is a FAILURE, not a skip: without the list the commit-leg expiry gate
|
|
6
|
+
* fails closed, so a feature / bugfix / refactor slice cannot complete. The
|
|
7
|
+
* doctor reports the same state (`severity: 'error'`) and names the seed the
|
|
8
|
+
* `peaks workspace init` command writes — the LLM runs it on the user's behalf.
|
|
9
|
+
*
|
|
10
|
+
* An uninitialized project (no `.peaks/`) is not this check's finding: the
|
|
11
|
+
* workspace-init check owns that state, and reporting here too would name the
|
|
12
|
+
* same root twice.
|
|
13
|
+
*/
|
|
14
|
+
import type { DoctorCheckPlugin } from '../types.js';
|
|
15
|
+
export declare const check: DoctorCheckPlugin;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check: the project carries the commit-leg back-compat acceptance list
|
|
3
|
+
* (`config:backcompat-acceptance`).
|
|
4
|
+
*
|
|
5
|
+
* Absence is a FAILURE, not a skip: without the list the commit-leg expiry gate
|
|
6
|
+
* fails closed, so a feature / bugfix / refactor slice cannot complete. The
|
|
7
|
+
* doctor reports the same state (`severity: 'error'`) and names the seed the
|
|
8
|
+
* `peaks workspace init` command writes — the LLM runs it on the user's behalf.
|
|
9
|
+
*
|
|
10
|
+
* An uninitialized project (no `.peaks/`) is not this check's finding: the
|
|
11
|
+
* workspace-init check owns that state, and reporting here too would name the
|
|
12
|
+
* same root twice.
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync } from 'node:fs';
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
const CHECK_ID = 'config:backcompat-acceptance';
|
|
17
|
+
const RELATIVE = '.peaks/lint/backcompat-expired-acceptance.json';
|
|
18
|
+
function run({ projectRootResolver }) {
|
|
19
|
+
const projectRoot = projectRootResolver();
|
|
20
|
+
if (projectRoot === null || !existsSync(join(projectRoot, '.peaks'))) {
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
id: CHECK_ID,
|
|
24
|
+
ok: true,
|
|
25
|
+
message: 'No initialized workspace to inspect for a back-compat acceptance list'
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
const absolute = join(projectRoot, '.peaks', 'lint', 'backcompat-expired-acceptance.json');
|
|
30
|
+
if (existsSync(absolute)) {
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
id: CHECK_ID,
|
|
34
|
+
ok: true,
|
|
35
|
+
message: `Back-compat acceptance list present (${RELATIVE})`
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
id: CHECK_ID,
|
|
42
|
+
ok: false,
|
|
43
|
+
severity: 'error',
|
|
44
|
+
message: `Back-compat acceptance list is absent (${RELATIVE}); the commit-leg expiry gate ` +
|
|
45
|
+
'fails closed. Ask the LLM to run `peaks workspace init --project <repo>` to seed it; ' +
|
|
46
|
+
"the LLM edits the tracked file on the user's behalf."
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
export const check = {
|
|
51
|
+
name: 'backcompat-acceptance',
|
|
52
|
+
run
|
|
53
|
+
};
|