peaks-loop 4.1.4 → 4.1.6
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 +7 -2
- package/CHANGELOG.md +148 -0
- package/README-en.md +47 -183
- package/README.md +24 -188
- package/dist/cli/cli-helpers.d.ts +20 -0
- package/dist/cli/cli-helpers.js +34 -0
- package/dist/cli/commands/_register.js +2 -0
- package/dist/cli/commands/best-practice-scan-command.d.ts +11 -6
- package/dist/cli/commands/best-practice-scan-command.js +35 -20
- package/dist/cli/commands/best-practice-scan-helpers.d.ts +47 -0
- package/dist/cli/commands/best-practice-scan-helpers.js +88 -5
- package/dist/cli/commands/best-practice-scan-lookup-results.d.ts +13 -0
- package/dist/cli/commands/best-practice-scan-lookup-results.js +237 -0
- package/dist/cli/commands/code-commands.d.ts +6 -4
- package/dist/cli/commands/code-commands.js +6 -4
- package/dist/cli/commands/code-gate-command.d.ts +5 -5
- package/dist/cli/commands/code-gate-command.js +49 -9
- package/dist/cli/commands/code-mode-gate-plan-command.d.ts +1 -1
- package/dist/cli/commands/code-mode-gate-plan-command.js +2 -2
- package/dist/cli/commands/core/memory-extract-command.js +10 -5
- package/dist/cli/commands/dispatch-cli-invocation-check.d.ts +108 -0
- package/dist/cli/commands/dispatch-cli-invocation-check.js +87 -0
- package/dist/cli/commands/dispatch-cli-invocation-scan.d.ts +66 -0
- package/dist/cli/commands/dispatch-cli-invocation-scan.js +162 -0
- package/dist/cli/commands/dispatch-command-spec.js +1 -1
- package/dist/cli/commands/dispatch-commands.js +12 -5
- package/dist/cli/commands/dispatch-isolation-lease.d.ts +1 -1
- package/dist/cli/commands/dispatch-isolation-lease.js +6 -53
- package/dist/cli/commands/dispatch-preflight.js +46 -0
- package/dist/cli/commands/dispatch-prompt-blocks.d.ts +1 -1
- package/dist/cli/commands/dispatch-prompt-composition.d.ts +7 -1
- package/dist/cli/commands/dispatch-prompt-composition.js +29 -7
- package/dist/cli/commands/dispatch-record-write.d.ts +1 -1
- package/dist/cli/commands/dispatch-tool-call.d.ts +1 -1
- package/dist/cli/commands/doc-commands.js +1 -1
- package/dist/cli/commands/feedback-commands-helpers.js +1 -1
- package/dist/cli/commands/final-review-prepare-command.js +22 -1
- package/dist/cli/commands/gate-commands-enforce.js +3 -3
- package/dist/cli/commands/hook-handle.js +41 -20
- package/dist/cli/commands/lint-commands.js +3 -1
- package/dist/cli/commands/loop-eval-capture-index.js +2 -4
- package/dist/cli/commands/openspec-command-shared.js +2 -2
- package/dist/cli/commands/perf-audit-commands.js +15 -5
- package/dist/cli/commands/project-commands.js +9 -6
- package/dist/cli/commands/race-commands.d.ts +15 -0
- package/dist/cli/commands/race-commands.js +65 -0
- package/dist/cli/commands/race-pilot-gate-record-command.d.ts +3 -0
- package/dist/cli/commands/race-pilot-gate-record-command.js +81 -0
- package/dist/cli/commands/request-command-options.d.ts +8 -0
- package/dist/cli/commands/request-commands.js +2 -0
- package/dist/cli/commands/request-init-command.js +67 -12
- package/dist/cli/commands/{vm-status-command.d.ts → request-retag-command.d.ts} +1 -1
- package/dist/cli/commands/request-retag-command.js +50 -0
- package/dist/cli/commands/request-show-command.d.ts +8 -0
- package/dist/cli/commands/request-show-command.js +14 -1
- package/dist/cli/commands/request-transition-command.js +12 -4
- package/dist/cli/commands/request-transition-failures.d.ts +14 -0
- package/dist/cli/commands/request-transition-failures.js +76 -7
- package/dist/cli/commands/request-transition-preflight.js +1 -1
- package/dist/cli/commands/scan-scope-commands.js +2 -2
- package/dist/cli/commands/security-audit-commands.js +26 -6
- package/dist/cli/commands/slice-decompose-artifacts.js +2 -1
- package/dist/cli/commands/verdict-aggregate-command.js +2 -1
- package/dist/cli/commands/workflow-gate-commands.js +4 -4
- package/dist/cli/commands/worktree-lease-gc-command.js +1 -1
- package/dist/cli/program.js +0 -2
- package/dist/services/artifacts/artifact-contract-block.d.ts +53 -0
- package/dist/services/artifacts/artifact-contract-block.js +231 -0
- package/dist/services/artifacts/artifact-prerequisites.d.ts +27 -19
- package/dist/services/artifacts/artifact-prerequisites.js +65 -135
- package/dist/services/artifacts/artifact-templates.d.ts +1 -1
- package/dist/services/artifacts/artifact-templates.js +17 -10
- package/dist/services/artifacts/prerequisite-checks.d.ts +87 -0
- package/dist/services/artifacts/prerequisite-checks.js +198 -0
- package/dist/services/artifacts/prerequisite-transition-event.d.ts +20 -0
- package/dist/services/artifacts/prerequisite-transition-event.js +27 -0
- package/dist/services/artifacts/rd-transition-gates.d.ts +33 -0
- package/dist/services/artifacts/rd-transition-gates.js +71 -0
- package/dist/services/artifacts/request-artifact-metadata.d.ts +31 -0
- package/dist/services/artifacts/request-artifact-metadata.js +44 -0
- package/dist/services/artifacts/request-artifact-service.d.ts +5 -0
- package/dist/services/artifacts/request-artifact-service.js +43 -69
- package/dist/services/artifacts/request-artifact-state-helpers.d.ts +21 -1
- package/dist/services/artifacts/request-artifact-state-helpers.js +34 -8
- package/dist/services/artifacts/request-retag-service.d.ts +68 -0
- package/dist/services/artifacts/request-retag-service.js +125 -0
- package/dist/services/artifacts/request-state-order.d.ts +38 -0
- package/dist/services/artifacts/request-state-order.js +99 -0
- package/dist/services/artifacts/request-type-demand.d.ts +44 -0
- package/dist/services/artifacts/request-type-demand.js +71 -0
- package/dist/services/audit/audit-goal-service.d.ts +7 -0
- package/dist/services/audit/enforcers/active-skill-resolver.d.ts +18 -0
- package/dist/services/audit/enforcers/active-skill-resolver.js +48 -1
- package/dist/services/audit/enforcers/code-ban.d.ts +11 -2
- package/dist/services/audit/enforcers/code-ban.js +21 -1
- package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.d.ts +17 -0
- package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.js +24 -7
- package/dist/services/audit-independent/handoff-missing-refusal.d.ts +26 -0
- package/dist/services/audit-independent/handoff-missing-refusal.js +109 -0
- package/dist/services/audit-independent/handoff-readers.d.ts +37 -0
- package/dist/services/audit-independent/handoff-readers.js +81 -0
- package/dist/services/audit-independent/index.d.ts +6 -1
- package/dist/services/audit-independent/index.js +6 -1
- package/dist/services/audit-independent/judged-declaration-build.d.ts +48 -0
- package/dist/services/audit-independent/judged-declaration-build.js +73 -0
- package/dist/services/audit-independent/judged-declaration-check.d.ts +80 -0
- package/dist/services/audit-independent/judged-declaration-check.js +216 -0
- package/dist/services/audit-independent/judged-declaration.d.ts +94 -0
- package/dist/services/audit-independent/judged-declaration.js +218 -0
- package/dist/services/audit-independent/perf-audit-service.js +12 -14
- package/dist/services/audit-independent/security-audit-artifact.d.ts +28 -0
- package/dist/services/audit-independent/security-audit-artifact.js +90 -0
- package/dist/services/audit-independent/security-audit-service.d.ts +6 -53
- package/dist/services/audit-independent/security-audit-service.js +34 -178
- package/dist/services/capability-guard-runner/contracts/J05.js +60 -14
- package/dist/services/codegraph/codegraph-index-integrity.js +2 -0
- package/dist/services/context/build-dispatch-system-prompt.d.ts +8 -12
- package/dist/services/context/build-dispatch-system-prompt.js +18 -18
- package/dist/services/context/collector.js +5 -1
- package/dist/services/context/post-compact-reinjection.js +1 -1
- package/dist/services/dispatch/active-dispatch-index.d.ts +36 -0
- package/dist/services/dispatch/active-dispatch-index.js +118 -0
- package/dist/services/dispatch/batch-counter.js +1 -2
- package/dist/services/dispatch/dispatch-record-writer.d.ts +29 -16
- package/dist/services/dispatch/dispatch-record-writer.js +58 -100
- package/dist/services/dispatch/dispatch-sub-agent.js +1 -1
- package/dist/services/dispatch/karpathy-block.d.ts +55 -0
- package/dist/services/dispatch/karpathy-block.js +101 -0
- package/dist/services/dispatch/ledger-reaper.d.ts +80 -0
- package/dist/services/dispatch/ledger-reaper.js +131 -0
- package/dist/services/dispatch/test-tool-detection.d.ts +17 -1
- package/dist/services/dispatch/test-tool-detection.js +12 -1
- package/dist/services/evidence/evidence-generator.js +23 -12
- package/dist/services/feedback/feedback-promotion-service.d.ts +8 -11
- package/dist/services/feedback/feedback-promotion-service.js +30 -35
- package/dist/services/feedback/promotion-artifact-json-evidence.d.ts +18 -0
- package/dist/services/feedback/promotion-artifact-missing.d.ts +22 -0
- package/dist/services/feedback/promotion-artifact-missing.js +63 -0
- package/dist/services/final-review/final-review-contract.d.ts +95 -4
- package/dist/services/final-review/final-review-contract.js +64 -0
- package/dist/services/final-review/final-review-delivery.d.ts +13 -0
- package/dist/services/final-review/final-review-delivery.js +26 -12
- package/dist/services/final-review/final-review-evidence-collect.js +8 -53
- package/dist/services/final-review/final-review-evidence-records.d.ts +21 -0
- package/dist/services/final-review/final-review-evidence-records.js +67 -0
- package/dist/services/final-review/final-review-evidence-sources.d.ts +22 -0
- package/dist/services/final-review/final-review-evidence-sources.js +28 -4
- package/dist/services/final-review/final-review-prompt.js +19 -6
- package/dist/services/final-review/final-review-runner.js +5 -0
- package/dist/services/final-review/final-review-service.d.ts +2 -2
- package/dist/services/final-review/index.d.ts +1 -1
- package/dist/services/final-review/pre-post-diff.d.ts +2 -75
- package/dist/services/final-review/pre-post-diff.js +60 -59
- package/dist/services/hooks/pre-tool-code-gate.d.ts +7 -1
- package/dist/services/hooks/pre-tool-code-gate.js +21 -2
- package/dist/services/hooks/worktree-authorization-gate.js +6 -31
- package/dist/services/hooks/worktree-refusal-messages.d.ts +74 -0
- package/dist/services/hooks/worktree-refusal-messages.js +102 -0
- package/dist/services/lint/eslint-runner-support.d.ts +1 -1
- package/dist/services/lint/eslint-runner-support.js +2 -1
- package/dist/services/lint/eslint-runner-types.d.ts +8 -0
- package/dist/services/lint/eslint-runner.js +17 -4
- package/dist/services/llm/anthropic-runner.js +24 -7
- package/dist/services/loop/loop-observability.d.ts +39 -0
- package/dist/services/loop/loop-observability.js +55 -0
- package/dist/services/loop/monotonic-guard.js +6 -9
- package/dist/services/loop/monotonic-runner.js +8 -7
- package/dist/services/loop/run-driver.js +18 -22
- package/dist/services/memory/project-memory-service/index/kind-dispatch.js +14 -1
- package/dist/services/memory/project-memory-service/index/project-memory-plan-exec.js +13 -2
- package/dist/services/memory/project-memory-service/index.d.ts +2 -2
- package/dist/services/memory/project-memory-service/index.js +1 -1
- package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.d.ts +36 -0
- package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.js +48 -2
- package/dist/services/memory/project-memory-service/parsers/markdown-pure.d.ts +23 -1
- package/dist/services/memory/project-memory-service/parsers/markdown-pure.js +37 -0
- package/dist/services/memory/project-memory-service/types.d.ts +32 -0
- package/dist/services/observability/observability-service.d.ts +7 -0
- package/dist/services/observability/observability-service.js +2 -1
- package/dist/services/openspec/coverage-evidence-reader.d.ts +9 -9
- package/dist/services/openspec/coverage-evidence-reader.js +8 -8
- package/dist/services/openspec/openspec-archive-service.d.ts +1 -1
- package/dist/services/openspec/openspec-archive-service.js +6 -6
- package/dist/services/prd/gate-evidence-derivation.d.ts +4 -3
- package/dist/services/prd/gate-evidence-derivation.js +4 -3
- package/dist/services/qa/bdd-test-style-verifier.js +22 -8
- package/dist/services/race/gate2-evaluator.d.ts +58 -0
- package/dist/services/race/gate2-evaluator.js +111 -0
- package/dist/services/race/gate2-policy.d.ts +17 -0
- package/dist/services/race/gate2-policy.js +31 -0
- package/dist/services/race/lane-phase.d.ts +19 -0
- package/dist/services/race/lane-phase.js +113 -0
- package/dist/services/race/pilot-gate-store.d.ts +67 -0
- package/dist/services/race/pilot-gate-store.js +227 -0
- package/dist/services/scan/file-size-baseline.d.ts +33 -0
- package/dist/services/scan/file-size-baseline.js +173 -0
- package/dist/services/scan/file-size-scan.d.ts +35 -3
- package/dist/services/scan/file-size-scan.js +63 -42
- package/dist/services/scan/type-corroboration.d.ts +32 -0
- package/dist/services/scan/type-corroboration.js +51 -0
- package/dist/services/scan/type-sanity-service.d.ts +14 -0
- package/dist/services/scan/type-sanity-service.js +23 -22
- package/dist/services/security/safe-settings-path.d.ts +5 -0
- package/dist/services/security/safe-settings-path.js +64 -8
- package/dist/services/skill/resume-detector.js +11 -11
- package/dist/services/skills/hooks-codegate-superpowers.d.ts +5 -6
- package/dist/services/skills/hooks-codegate-superpowers.js +7 -8
- package/dist/services/skills/hooks-settings-service.d.ts +1 -1
- package/dist/services/skills/hooks-settings-service.js +1 -1
- package/dist/services/skills/presence-lease-order.d.ts +13 -0
- package/dist/services/skills/presence-lease-order.js +24 -0
- package/dist/services/skills/skill-conformance-service.js +1 -0
- package/dist/services/skills/skill-statusline-service.js +4 -7
- package/dist/services/slice/slice-check-service.js +8 -8
- package/dist/services/workflow/pipeline-verify-gate-support.d.ts +24 -8
- package/dist/services/workflow/pipeline-verify-gate-support.js +34 -39
- package/dist/services/workflow/pipeline-verify-qa-phase.d.ts +102 -0
- package/dist/services/workflow/pipeline-verify-qa-phase.js +176 -0
- package/dist/services/workflow/pipeline-verify-service.js +27 -28
- package/dist/services/workflow/request-type-resolution.d.ts +99 -0
- package/dist/services/workflow/request-type-resolution.js +130 -0
- package/dist/services/workflow/workflow-skip-service.d.ts +1 -20
- package/dist/services/workflow/workflow-skip-service.js +22 -25
- package/dist/services/workflow/workflow-state-store.d.ts +9 -0
- package/dist/services/workflow/workflow-state-store.js +26 -1
- package/dist/services/workspace/claude-settings-retirements.d.ts +54 -0
- package/dist/services/workspace/claude-settings-retirements.js +112 -0
- package/dist/services/workspace/claude-settings-template-merge.d.ts +35 -15
- package/dist/services/workspace/claude-settings-template-merge.js +33 -53
- package/dist/services/workspace/claude-settings-template.d.ts +62 -12
- package/dist/services/workspace/claude-settings-template.js +58 -58
- package/dist/services/workspace/migrate-1-4-1-service.js +3 -0
- package/dist/services/workspace/reconcile-service.js +0 -1
- package/dist/shared/incrementing-number.d.ts +33 -2
- package/dist/shared/incrementing-number.js +72 -3
- package/package.json +5 -7
- package/skills/bee/peaks-perf-audit/SKILL.md +1 -1
- package/skills/bee/peaks-prd/SKILL.md +4 -3
- package/skills/bee/peaks-qa/SKILL.md +1 -1
- package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +2 -2
- package/skills/bee/peaks-qa/references/qa-transition-gates.md +1 -1
- package/skills/bee/peaks-rd/SKILL.md +2 -2
- package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +1 -1
- package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +8 -4
- package/skills/bee/peaks-rd/references/rd-transition-gates.md +3 -3
- package/skills/bee/peaks-rd/references/v2-12-fanout-collapse.md +2 -2
- package/skills/bee/peaks-rd/references/writing-handoff-frontmatter.md +1 -1
- package/skills/bee/peaks-reviewer/SKILL.md +1 -1
- package/skills/bee/peaks-sc/SKILL.md +1 -1
- package/skills/bee/peaks-security-audit/SKILL.md +10 -2
- package/skills/bee/peaks-txt/SKILL.md +4 -3
- package/skills/bee/peaks-ui/SKILL.md +3 -3
- package/skills/peaks-audit/SKILL.md +29 -1
- package/skills/peaks-code/SKILL.md +37 -17
- package/skills/peaks-code/references/fast-lane-norm.md +42 -0
- package/skills/peaks-code/references/fast-mode.md +3 -2
- package/skills/peaks-code/references/local-artifact-workspace.md +3 -3
- package/skills/peaks-code/references/micro-cycle.md +3 -3
- package/skills/peaks-code/references/resume-detection.md +1 -1
- package/skills/peaks-code/references/runbook.md +12 -6
- package/skills/peaks-code/references/step-11-memory-sediment.md +4 -0
- package/skills/peaks-code/references/sub-agent-dispatch.md +1 -1
- package/skills/peaks-code/references/swarm-dispatch-contract.md +40 -16
- package/skills/peaks-code/references/workflow-gates-and-types.md +6 -6
- package/skills/peaks-code/references/worktree-governance.md +4 -4
- package/skills/peaks-content/SKILL.md +1 -1
- package/skills/peaks-doctor/SKILL.md +1 -1
- package/skills/peaks-final-review/SKILL.md +31 -11
- package/skills/peaks-ide/SKILL.md +1 -1
- package/skills/peaks-issue-fix-orchestrator/SKILL.md +1 -1
- package/skills/peaks-race-code/SKILL.md +185 -0
- package/skills/peaks-resume/SKILL.md +1 -1
- package/skills/peaks-slice-decompose/SKILL.md +1 -1
- package/skills/peaks-solo/SKILL.md +1 -1
- package/skills/peaks-sop/SKILL.md +1 -1
- package/skills/peaks-status/SKILL.md +1 -1
- package/skills/peaks-test/SKILL.md +7 -4
- package/dist/cli/commands/vm-command-shared.d.ts +0 -23
- package/dist/cli/commands/vm-command-shared.js +0 -23
- package/dist/cli/commands/vm-commands.d.ts +0 -3
- package/dist/cli/commands/vm-commands.js +0 -45
- package/dist/cli/commands/vm-hypervisor-probe.d.ts +0 -27
- package/dist/cli/commands/vm-hypervisor-probe.js +0 -78
- package/dist/cli/commands/vm-hypervisor-runtime.d.ts +0 -15
- package/dist/cli/commands/vm-hypervisor-runtime.js +0 -64
- package/dist/cli/commands/vm-release-command.d.ts +0 -5
- package/dist/cli/commands/vm-release-command.js +0 -101
- package/dist/cli/commands/vm-spawn-command.d.ts +0 -5
- package/dist/cli/commands/vm-spawn-command.js +0 -177
- package/dist/cli/commands/vm-status-command.js +0 -50
- package/dist/services/audit/enforcers/lint-peaks-skill-runtime.d.ts +0 -23
- package/dist/services/audit/enforcers/lint-peaks-skill-runtime.js +0 -64
- package/dist/services/vm/vm-lease.d.ts +0 -40
- package/dist/services/vm/vm-lease.js +0 -160
|
@@ -11,19 +11,21 @@
|
|
|
11
11
|
* paths compile unchanged.
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { markQaRequestGate, typeRequiresQaPhase } from './pipeline-verify-qa-phase.js';
|
|
15
|
+
import { NO_SESSION_SCOPE, mayHonourSkip, resolveRequestType } from './request-type-resolution.js';
|
|
15
16
|
import { readSkipState } from './workflow-state-store.js';
|
|
16
17
|
import { getSessionIdCanonical } from '../session/session-manager.js';
|
|
17
18
|
import { listPromotionExempt, listUnpromotedFeedback } from '../feedback/feedback-promotion-service.js';
|
|
18
19
|
import { QA_COMPLETE_STATES, RD_QA_HANDOFF_STATES, extractState, findRequestFile, qaGatesForType, rdGatesForType, resolveQaEvidencePaths, resolveRdEvidencePaths } from './pipeline-verify-gate-support.js';
|
|
19
20
|
export async function verifyPipeline(options) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const violations = [];
|
|
21
|
+
// ONE scope for every read: the session, or NONE — never a scan.
|
|
22
|
+
const sessionId = options.sessionId ?? getSessionIdCanonical(options.projectRoot);
|
|
23
|
+
const requestType = await resolveRequestType({ ...options, sessionId });
|
|
24
|
+
const violations = sessionId === null ? [NO_SESSION_SCOPE] : [];
|
|
24
25
|
const nextActions = [];
|
|
25
26
|
const rdGates = rdGatesForType(requestType);
|
|
26
27
|
const qaGates = qaGatesForType(requestType);
|
|
28
|
+
const qaPhaseRequired = typeRequiresQaPhase(requestType);
|
|
27
29
|
// and pre-mark matching gates as `status: 'skipped'`. We do this
|
|
28
30
|
// BEFORE evaluating evidence files, so a skipped gate never
|
|
29
31
|
// emits a "missing evidence" violation. The boolean `passed` is
|
|
@@ -31,7 +33,7 @@ export async function verifyPipeline(options) {
|
|
|
31
33
|
// treat skipped gates as satisfied; the new `status` field
|
|
32
34
|
// distinguishes the bypass from an actual pass.
|
|
33
35
|
const skippedGateNames = new Set();
|
|
34
|
-
if (options.sessionId !== undefined) {
|
|
36
|
+
if (options.sessionId !== undefined && mayHonourSkip(requestType)) {
|
|
35
37
|
const skipState = readSkipState(options.projectRoot, options.sessionId, options.rid);
|
|
36
38
|
if (skipState !== null) {
|
|
37
39
|
for (const gateName of skipState.skippedGates) {
|
|
@@ -47,7 +49,7 @@ export async function verifyPipeline(options) {
|
|
|
47
49
|
skippedGateNames.add(gateName);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
|
-
nextActions.push(`Skipped gates (via peaks workflow skip): [${skipState.skippedGates.join(', ')}] — reason: ${skipState.skipReason}`);
|
|
52
|
+
nextActions.push(`Skipped gates (via peaks workflow skip): [${skipState.skippedGates.join(', ')}] — reason: ${skipState.skipReason} (record says applied by ${skipState.skipAppliedBy} at ${skipState.skipAppliedAt}, caller: ${skipState.callerKind})`);
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
function markIfSkipped(gate) {
|
|
@@ -59,7 +61,7 @@ export async function verifyPipeline(options) {
|
|
|
59
61
|
}
|
|
60
62
|
// Resolve RD + QA on-disk locations via showRequestArtifact (the change-id
|
|
61
63
|
// is whatever dir the file actually lives in, not the caller's session-id).
|
|
62
|
-
const rdFile = await findRequestFile(options.projectRoot, 'rd', options.rid);
|
|
64
|
+
const rdFile = await findRequestFile(options.projectRoot, 'rd', options.rid, sessionId);
|
|
63
65
|
let rdInvoked = false;
|
|
64
66
|
let rdState = 'missing';
|
|
65
67
|
// The resolved change-id is the on-disk location the file actually
|
|
@@ -89,33 +91,31 @@ export async function verifyPipeline(options) {
|
|
|
89
91
|
// detail / nextActions surface the `DEPRECATION_LEGACY_PATH_USED`
|
|
90
92
|
// warning so QA / TXT can nudge users to migrate via
|
|
91
93
|
// `peaks workspace migrate`.
|
|
92
|
-
// v2.18.1 bug #5 fix: when `resolvedChangeId` is empty (no RD/QA
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
// a
|
|
97
|
-
const rdEvidenceDir = resolvedChangeId ||
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const rdTracker = resolveRdEvidencePaths(rdGates, rdEvidenceDir, options.projectRoot, options.rid, requestType, violations, nextActions, { anyEvidenceResolved: false, allResolvedPathsCanonical: true });
|
|
94
|
+
// v2.18.1 bug #5 fix: when `resolvedChangeId` is empty (no RD/QA artifact on
|
|
95
|
+
// disk yet), the canonical session id from the binding-store is the scope.
|
|
96
|
+
//
|
|
97
|
+
// THE RID IS NOT A SCOPE: this chain used to end at `options.rid`, reading
|
|
98
|
+
// EVIDENCE out of a directory named after the rid. An empty scope reads none.
|
|
99
|
+
const rdEvidenceDir = resolvedChangeId || options.sessionId || getSessionIdCanonical(options.projectRoot) || '';
|
|
100
|
+
// An empty gate list IS "no evidence read": the resolver walks the gates it is
|
|
101
|
+
// handed, so no second branch has to be kept in step with this one.
|
|
102
|
+
const rdTracker = resolveRdEvidencePaths(rdEvidenceDir === '' ? [] : rdGates, rdEvidenceDir, options.projectRoot, options.rid, requestType, violations, nextActions, { anyEvidenceResolved: false, allResolvedPathsCanonical: true });
|
|
102
103
|
// Check if RD reached qa-handoff
|
|
103
104
|
if (rdInvoked && !RD_QA_HANDOFF_STATES.has(rdState)) {
|
|
104
105
|
violations.push(`RD not ready for QA: state is "${rdState}" — must reach "qa-handoff" (unit tests, karpathy-guidelines §1 Think / §2 Simplicity / §3 Surgical / §4 Goal-Driven, code review, security review complete)`);
|
|
105
106
|
nextActions.push(`Complete RD gates → peaks request transition ${options.rid} --role rd --state qa-handoff`);
|
|
106
107
|
}
|
|
107
108
|
// Check QA phase
|
|
108
|
-
const qaFile = await findRequestFile(options.projectRoot, 'qa', options.rid);
|
|
109
|
+
const qaFile = await findRequestFile(options.projectRoot, 'qa', options.rid, sessionId);
|
|
109
110
|
let qaInvoked = false;
|
|
110
111
|
let qaState = 'missing';
|
|
111
112
|
if (qaFile) {
|
|
112
113
|
qaInvoked = true;
|
|
113
114
|
qaState = extractState(qaFile.content);
|
|
114
|
-
qaGates
|
|
115
|
-
qaGates[0].detail = `found at ${qaFile.path}`;
|
|
115
|
+
markQaRequestGate(qaGates, qaFile.path);
|
|
116
116
|
resolvedChangeId = qaFile.sessionId || resolvedChangeId;
|
|
117
117
|
}
|
|
118
|
-
else {
|
|
118
|
+
else if (qaPhaseRequired) {
|
|
119
119
|
violations.push('QA phase skipped: peaks-qa was never invoked for this request (no QA request artifact found)');
|
|
120
120
|
nextActions.push('Invoke Skill(skill="peaks-qa") with the request-id for functional/performance/security testing');
|
|
121
121
|
qaGates[0].detail = 'not found';
|
|
@@ -123,7 +123,7 @@ export async function verifyPipeline(options) {
|
|
|
123
123
|
// Check QA evidence files. (The v2.18.1 bug #5 `changeIdForResolver`
|
|
124
124
|
// fallback — current session id when no RD/QA artifact is on disk yet —
|
|
125
125
|
// the security/perf findings branch that was its only consumer.)
|
|
126
|
-
const qaTracker = resolveQaEvidencePaths(qaGates, options.projectRoot, rdEvidenceDir, requestType, options.rid, violations, nextActions, rdTracker);
|
|
126
|
+
const qaTracker = resolveQaEvidencePaths(rdEvidenceDir === '' ? [] : qaGates, options.projectRoot, rdEvidenceDir, requestType, options.rid, violations, nextActions, rdTracker);
|
|
127
127
|
const anyEvidenceResolved = qaTracker.anyEvidenceResolved;
|
|
128
128
|
const allResolvedPathsCanonical = qaTracker.allResolvedPathsCanonical;
|
|
129
129
|
// Check if QA reached verdict-issued
|
|
@@ -167,7 +167,7 @@ export async function verifyPipeline(options) {
|
|
|
167
167
|
// Resolve the "RD invoked without QA" check now that markIfSkipped
|
|
168
168
|
// has run. The check is suppressed when every QA gate is skipped
|
|
169
169
|
// to skip the QA phase).
|
|
170
|
-
if (rdInvokedWithoutQaRaw) {
|
|
170
|
+
if (rdInvokedWithoutQaRaw && qaPhaseRequired) {
|
|
171
171
|
const allQaSkipped = qaGates.every((g) => g.status === 'skipped');
|
|
172
172
|
if (!allQaSkipped) {
|
|
173
173
|
violations.push('CRITICAL: peaks-rd was invoked but peaks-qa was NOT — QA functional/performance/security testing is mandatory after all RD work');
|
|
@@ -209,7 +209,7 @@ export async function verifyPipeline(options) {
|
|
|
209
209
|
// artifact is absent, so `unpromoted` mixes "never promoted" with
|
|
210
210
|
// "promoted on paper only" — the reason on each entry says which.
|
|
211
211
|
feedbackGates[0].detail = `${unpromoted.length} feedback memor${unpromoted.length === 1 ? 'y' : 'ies'} without a backed promotion: ${unpromoted.map((u) => `${u.name} (${u.reason})`).join('; ')}${exemptNote}`;
|
|
212
|
-
violations.push(`Gate H feedback-promotion FAILED: ${unpromoted.length} feedback memor${unpromoted.length === 1 ? 'y is' : 'ies are'} not yet promoted to an enforcement layer with a real artifact (${unpromoted.map((u) => u.name).join(', ')})${exemptNote}. A marker alone does not count: layer A needs a registered SOP manifest, layer B a hook command that runs something named after the rule in .peaks/.claude-settings-template.json, layer C a hard-floor category in src/services/code/mode-gate.ts. Run \`peaks feedback promote <memory-file> --layer <A|B|C>\` for each and read what it reports. See sops/feedback-promotion-sop.md.`);
|
|
212
|
+
violations.push(`Gate H feedback-promotion FAILED: ${unpromoted.length} feedback memor${unpromoted.length === 1 ? 'y is' : 'ies are'} not yet promoted to an enforcement layer with a real artifact (${unpromoted.map((u) => u.name).join(', ')})${exemptNote}. A marker alone does not count: layer A needs a registered SOP manifest, layer B a hook command that runs something named after the rule in .peaks/.claude-settings-template.json or the tracked .claude/settings.json, layer C a hard-floor category in src/services/code/mode-gate.ts. Run \`peaks feedback promote <memory-file> --layer <A|B|C>\` for each and read what it reports. See sops/feedback-promotion-sop.md.`);
|
|
213
213
|
nextActions.push(`Run \`peaks feedback promote <memory-file> --layer <A|B|C>\` for each feedback memory without a backed promotion to satisfy Gate H.`);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
@@ -226,12 +226,11 @@ export async function verifyPipeline(options) {
|
|
|
226
226
|
const allRdGatesPassed = rdGates.every((g) => g.passed);
|
|
227
227
|
const allQaGatesPassed = qaGates.every((g) => g.passed);
|
|
228
228
|
const complete = rdInvoked &&
|
|
229
|
-
qaInvoked &&
|
|
229
|
+
(qaInvoked ? QA_COMPLETE_STATES.has(qaState) : !qaPhaseRequired) &&
|
|
230
230
|
allRdGatesPassed &&
|
|
231
231
|
allQaGatesPassed &&
|
|
232
232
|
allFeedbackGatesPassed &&
|
|
233
|
-
RD_QA_HANDOFF_STATES.has(rdState)
|
|
234
|
-
QA_COMPLETE_STATES.has(qaState);
|
|
233
|
+
RD_QA_HANDOFF_STATES.has(rdState);
|
|
235
234
|
// 'suffixed' when the contract's current path served the file and 'legacy'
|
|
236
235
|
// when the deprecated fallback did; 'none' if neither gate passed.
|
|
237
236
|
//
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which request type this rid declares — DERIVED, so no caller can get it wrong.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS EXISTS. `verifyPipeline` took the request type as an option and fell
|
|
5
|
+
* back to `feature` when it was absent. The two callers that matter both left it
|
|
6
|
+
* absent — `peaks workflow verify-pipeline` passes it only when a human types
|
|
7
|
+
* `--type`, and `slice-check` never passes it — so the CHECKER read every rid as
|
|
8
|
+
* `feature` while the commit-time carrier read the rid's own `- type:` line and
|
|
9
|
+
* got it right. For a docs or chore request those two readers disagreed on the
|
|
10
|
+
* same tree: `verify-pipeline` reported three RD-evidence violations and
|
|
11
|
+
* `complete: false`, and the commit leg reported the contract satisfied.
|
|
12
|
+
*
|
|
13
|
+
* That is the same defect one layer up from the gate list: two layers answering
|
|
14
|
+
* one question, each with its own answer. So the answer is derived here, in ONE
|
|
15
|
+
* place, and every caller inherits it — `--type` stays as the explicit override.
|
|
16
|
+
*
|
|
17
|
+
* THE RULE IS THE CARRIER'S OWN, deliberately. `CARRIER_ROLES` is the order
|
|
18
|
+
* `.husky/pipeline/contract-verdict.mjs` enumerates a rid's carriers in
|
|
19
|
+
* (`CARRIER_DIRS`), and the first carrier that exists answers — including when its
|
|
20
|
+
* answer is the reader's substituted default, which is what that leg does with an
|
|
21
|
+
* unusable or absent `- type:` line.
|
|
22
|
+
*
|
|
23
|
+
* THE SCOPE IS THE CARRIER'S OWN TOO, AND THAT PART CAME SECOND. Matching the
|
|
24
|
+
* ORDER while scanning every directory under `.peaks/_runtime/` was a security
|
|
25
|
+
* defect, not a style question: a directory whose name sorted before the rid's
|
|
26
|
+
* session won, so anyone able to create one file under `.peaks/_runtime/` could
|
|
27
|
+
* choose ANY rid's gate table — silently, with the type looking like an ordinary
|
|
28
|
+
* derivation. Measured before the fix: a docs rid read as `feature`, `complete`
|
|
29
|
+
* true → false, with an empty 16-byte file in a directory beside it.
|
|
30
|
+
*
|
|
31
|
+
* So a carrier is read from a SESSION and never from a bare directory: the caller's
|
|
32
|
+
* session when it named one, else the canonical binding's, else the fail-closed
|
|
33
|
+
* default. Two further review rounds measured what the middle grounds cost — a
|
|
34
|
+
* session chosen by its directory NAME, then a directory named after the request
|
|
35
|
+
* itself, read as the EVIDENCE scope — and each is now shut off in the module that
|
|
36
|
+
* owns that axis. See `sessionsToRead` and, for the evidence half,
|
|
37
|
+
* `pipeline-verify-service.ts`'s empty-scope guard.
|
|
38
|
+
*
|
|
39
|
+
* WHAT "READS NOTHING" COVERS, STATED EXACTLY: the type (this module), the request
|
|
40
|
+
* artifact (`findRequestFile`, which answers null for a null scope), and the
|
|
41
|
+
* evidence (`resolveRdEvidencePaths` / `resolveQaEvidencePaths`, which are handed
|
|
42
|
+
* an empty gate list). All three axes, or the sentence is the kind of comment this
|
|
43
|
+
* slice exists to remove.
|
|
44
|
+
*/
|
|
45
|
+
import { type RequestType } from '../artifacts/artifact-prerequisites.js';
|
|
46
|
+
/**
|
|
47
|
+
* The rid's carriers, in the order the commit-time leg reads them: the RD request
|
|
48
|
+
* is the slice's own record, and a PRD- or QA-only rid still answers.
|
|
49
|
+
*
|
|
50
|
+
* EXPORTED FOR ITS PARITY ARM, and that is not decoration. These three roles and
|
|
51
|
+
* `.husky/pipeline/contract-verdict.mjs`'s `CARRIER_DIRS` are two literals held
|
|
52
|
+
* equal by a comment, which is the duplicate-derivation pattern this whole line of
|
|
53
|
+
* work exists to remove. They cannot be one literal without a layering inversion —
|
|
54
|
+
* the hook reads `src/` dynamically and lazily, and `src/` may not read `.husky/` —
|
|
55
|
+
* so an arm asserts the equality instead, and a reorder on either side reddens it.
|
|
56
|
+
*/
|
|
57
|
+
export declare const CARRIER_ROLES: readonly ["rd", "prd", "qa"];
|
|
58
|
+
/**
|
|
59
|
+
* Whether a skip may be HONOURED for a request of this type — the request-type
|
|
60
|
+
* rule, asserted again when a skip is READ.
|
|
61
|
+
*
|
|
62
|
+
* WHY THE READ RE-ASSERTS IT. `isWorkflowSkipState` validates field PRESENCE only;
|
|
63
|
+
* the three write-time rules (this allowlist, one-time, caller kind) live in
|
|
64
|
+
* `canSkipSlice`, so a hand-planted file satisfies the shape and none of the rules.
|
|
65
|
+
* Measured: a planted file flipped the commit leg from refusing a FEATURE rid with
|
|
66
|
+
* six missing artifacts to passing it. A reader that acts on the record is trusting
|
|
67
|
+
* a carrier, which is the thing this line of work exists to stop.
|
|
68
|
+
*
|
|
69
|
+
* It lives here, beside the request type, because the rule IS a statement about the
|
|
70
|
+
* request type; it reuses `SKIPPABLE_TYPES` rather than respelling the allowlist.
|
|
71
|
+
* WHAT IT CANNOT DO: for a type the allowlist permits the record IS the
|
|
72
|
+
* authorization, and a reader cannot tell a planted one from a written one — the
|
|
73
|
+
* measured axis is the forbidden one, and the residual is in the RD artifact.
|
|
74
|
+
*/
|
|
75
|
+
export declare function mayHonourSkip(requestType: RequestType): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* What a caller is told when no scope resolves — the refusal names itself and
|
|
78
|
+
* names the remedy, rather than reporting a missing artifact nobody can act on.
|
|
79
|
+
*/
|
|
80
|
+
export declare const NO_SESSION_SCOPE = "No session scope resolved: name one with --session-id <id>, or run inside a tree that has a peaks session binding. Nothing is read without one \u2014 not a carrier from some other directory, and not evidence from a directory named after this request.";
|
|
81
|
+
/**
|
|
82
|
+
* The type of `rid`, or `request.requestType` when that is a request type.
|
|
83
|
+
*
|
|
84
|
+
* `request.requestType` is the caller's `--type`: an explicit, validated override.
|
|
85
|
+
* It is checked against the same membership rule the artifacts layer uses, so a
|
|
86
|
+
* typo falls through to the derivation rather than selecting a table by accident.
|
|
87
|
+
*
|
|
88
|
+
* The parameter is the request's own identity, which is what every caller already
|
|
89
|
+
* has to hand — so no caller has to remember a separate argument.
|
|
90
|
+
*/
|
|
91
|
+
export declare function resolveRequestType(request: {
|
|
92
|
+
projectRoot: string;
|
|
93
|
+
rid: string;
|
|
94
|
+
/** The caller's `--type`, when it passed one. */
|
|
95
|
+
requestType?: string;
|
|
96
|
+
/** The session the caller is working in, when it named one. `null` is a
|
|
97
|
+
* resolved answer too: it means no scope could be resolved. */
|
|
98
|
+
sessionId?: string | null | undefined;
|
|
99
|
+
}): Promise<RequestType>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which request type this rid declares — DERIVED, so no caller can get it wrong.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS EXISTS. `verifyPipeline` took the request type as an option and fell
|
|
5
|
+
* back to `feature` when it was absent. The two callers that matter both left it
|
|
6
|
+
* absent — `peaks workflow verify-pipeline` passes it only when a human types
|
|
7
|
+
* `--type`, and `slice-check` never passes it — so the CHECKER read every rid as
|
|
8
|
+
* `feature` while the commit-time carrier read the rid's own `- type:` line and
|
|
9
|
+
* got it right. For a docs or chore request those two readers disagreed on the
|
|
10
|
+
* same tree: `verify-pipeline` reported three RD-evidence violations and
|
|
11
|
+
* `complete: false`, and the commit leg reported the contract satisfied.
|
|
12
|
+
*
|
|
13
|
+
* That is the same defect one layer up from the gate list: two layers answering
|
|
14
|
+
* one question, each with its own answer. So the answer is derived here, in ONE
|
|
15
|
+
* place, and every caller inherits it — `--type` stays as the explicit override.
|
|
16
|
+
*
|
|
17
|
+
* THE RULE IS THE CARRIER'S OWN, deliberately. `CARRIER_ROLES` is the order
|
|
18
|
+
* `.husky/pipeline/contract-verdict.mjs` enumerates a rid's carriers in
|
|
19
|
+
* (`CARRIER_DIRS`), and the first carrier that exists answers — including when its
|
|
20
|
+
* answer is the reader's substituted default, which is what that leg does with an
|
|
21
|
+
* unusable or absent `- type:` line.
|
|
22
|
+
*
|
|
23
|
+
* THE SCOPE IS THE CARRIER'S OWN TOO, AND THAT PART CAME SECOND. Matching the
|
|
24
|
+
* ORDER while scanning every directory under `.peaks/_runtime/` was a security
|
|
25
|
+
* defect, not a style question: a directory whose name sorted before the rid's
|
|
26
|
+
* session won, so anyone able to create one file under `.peaks/_runtime/` could
|
|
27
|
+
* choose ANY rid's gate table — silently, with the type looking like an ordinary
|
|
28
|
+
* derivation. Measured before the fix: a docs rid read as `feature`, `complete`
|
|
29
|
+
* true → false, with an empty 16-byte file in a directory beside it.
|
|
30
|
+
*
|
|
31
|
+
* So a carrier is read from a SESSION and never from a bare directory: the caller's
|
|
32
|
+
* session when it named one, else the canonical binding's, else the fail-closed
|
|
33
|
+
* default. Two further review rounds measured what the middle grounds cost — a
|
|
34
|
+
* session chosen by its directory NAME, then a directory named after the request
|
|
35
|
+
* itself, read as the EVIDENCE scope — and each is now shut off in the module that
|
|
36
|
+
* owns that axis. See `sessionsToRead` and, for the evidence half,
|
|
37
|
+
* `pipeline-verify-service.ts`'s empty-scope guard.
|
|
38
|
+
*
|
|
39
|
+
* WHAT "READS NOTHING" COVERS, STATED EXACTLY: the type (this module), the request
|
|
40
|
+
* artifact (`findRequestFile`, which answers null for a null scope), and the
|
|
41
|
+
* evidence (`resolveRdEvidencePaths` / `resolveQaEvidencePaths`, which are handed
|
|
42
|
+
* an empty gate list). All three axes, or the sentence is the kind of comment this
|
|
43
|
+
* slice exists to remove.
|
|
44
|
+
*/
|
|
45
|
+
import { DEFAULT_REQUEST_TYPE, isRequestType } from '../artifacts/artifact-prerequisites.js';
|
|
46
|
+
import { showRequestArtifact } from '../artifacts/request-artifact-service.js';
|
|
47
|
+
import { getSessionIdCanonical } from '../session/session-manager.js';
|
|
48
|
+
import { SKIPPABLE_TYPES } from './workflow-skip-service.js';
|
|
49
|
+
/**
|
|
50
|
+
* The rid's carriers, in the order the commit-time leg reads them: the RD request
|
|
51
|
+
* is the slice's own record, and a PRD- or QA-only rid still answers.
|
|
52
|
+
*
|
|
53
|
+
* EXPORTED FOR ITS PARITY ARM, and that is not decoration. These three roles and
|
|
54
|
+
* `.husky/pipeline/contract-verdict.mjs`'s `CARRIER_DIRS` are two literals held
|
|
55
|
+
* equal by a comment, which is the duplicate-derivation pattern this whole line of
|
|
56
|
+
* work exists to remove. They cannot be one literal without a layering inversion —
|
|
57
|
+
* the hook reads `src/` dynamically and lazily, and `src/` may not read `.husky/` —
|
|
58
|
+
* so an arm asserts the equality instead, and a reorder on either side reddens it.
|
|
59
|
+
*/
|
|
60
|
+
export const CARRIER_ROLES = ['rd', 'prd', 'qa'];
|
|
61
|
+
/**
|
|
62
|
+
* Whether a skip may be HONOURED for a request of this type — the request-type
|
|
63
|
+
* rule, asserted again when a skip is READ.
|
|
64
|
+
*
|
|
65
|
+
* WHY THE READ RE-ASSERTS IT. `isWorkflowSkipState` validates field PRESENCE only;
|
|
66
|
+
* the three write-time rules (this allowlist, one-time, caller kind) live in
|
|
67
|
+
* `canSkipSlice`, so a hand-planted file satisfies the shape and none of the rules.
|
|
68
|
+
* Measured: a planted file flipped the commit leg from refusing a FEATURE rid with
|
|
69
|
+
* six missing artifacts to passing it. A reader that acts on the record is trusting
|
|
70
|
+
* a carrier, which is the thing this line of work exists to stop.
|
|
71
|
+
*
|
|
72
|
+
* It lives here, beside the request type, because the rule IS a statement about the
|
|
73
|
+
* request type; it reuses `SKIPPABLE_TYPES` rather than respelling the allowlist.
|
|
74
|
+
* WHAT IT CANNOT DO: for a type the allowlist permits the record IS the
|
|
75
|
+
* authorization, and a reader cannot tell a planted one from a written one — the
|
|
76
|
+
* measured axis is the forbidden one, and the residual is in the RD artifact.
|
|
77
|
+
*/
|
|
78
|
+
export function mayHonourSkip(requestType) {
|
|
79
|
+
return SKIPPABLE_TYPES.includes(requestType);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* What a caller is told when no scope resolves — the refusal names itself and
|
|
83
|
+
* names the remedy, rather than reporting a missing artifact nobody can act on.
|
|
84
|
+
*/
|
|
85
|
+
export const NO_SESSION_SCOPE = 'No session scope resolved: name one with --session-id <id>, or run inside a tree that has a peaks session binding. Nothing is read without one — not a carrier from some other directory, and not evidence from a directory named after this request.';
|
|
86
|
+
/**
|
|
87
|
+
* The one session this rid's carriers may be read from: the caller's, or the
|
|
88
|
+
* canonical binding's. NOTHING when neither resolves.
|
|
89
|
+
*
|
|
90
|
+
* WHY NOTHING, AND NOT A LIST OF "RECOGNISED" SESSIONS. An earlier version fell
|
|
91
|
+
* back to `discoverSessions` when no session resolved — and "recognised" is a
|
|
92
|
+
* DIRECTORY NAME (`/^\d{4}-\d{2}-\d{2}-session-[a-f0-9]+$/`) sorted ascending, so
|
|
93
|
+
* a writer-chosen name decided the gate table on any tree where no session
|
|
94
|
+
* resolved; measured through the CLI, that turned a refused rid into
|
|
95
|
+
* `complete: true` with no violations. A name is not a proof of which session is
|
|
96
|
+
* being verified, and an unbound tree cannot say — so the answer is the
|
|
97
|
+
* fail-closed default, and the caller names the session when it knows one.
|
|
98
|
+
*/
|
|
99
|
+
function sessionsToRead(request) {
|
|
100
|
+
const named = request.sessionId ?? getSessionIdCanonical(request.projectRoot);
|
|
101
|
+
return named === null ? [] : [named];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The type of `rid`, or `request.requestType` when that is a request type.
|
|
105
|
+
*
|
|
106
|
+
* `request.requestType` is the caller's `--type`: an explicit, validated override.
|
|
107
|
+
* It is checked against the same membership rule the artifacts layer uses, so a
|
|
108
|
+
* typo falls through to the derivation rather than selecting a table by accident.
|
|
109
|
+
*
|
|
110
|
+
* The parameter is the request's own identity, which is what every caller already
|
|
111
|
+
* has to hand — so no caller has to remember a separate argument.
|
|
112
|
+
*/
|
|
113
|
+
export async function resolveRequestType(request) {
|
|
114
|
+
if (isRequestType(request.requestType ?? ''))
|
|
115
|
+
return request.requestType;
|
|
116
|
+
for (const sessionId of sessionsToRead(request)) {
|
|
117
|
+
for (const role of CARRIER_ROLES) {
|
|
118
|
+
const artifact = await showRequestArtifact({
|
|
119
|
+
projectRoot: request.projectRoot,
|
|
120
|
+
role,
|
|
121
|
+
requestId: request.rid,
|
|
122
|
+
sessionId
|
|
123
|
+
});
|
|
124
|
+
if (artifact === null)
|
|
125
|
+
continue;
|
|
126
|
+
return artifact.requestType;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return DEFAULT_REQUEST_TYPE;
|
|
130
|
+
}
|
|
@@ -1,25 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* Pure-function classifier (`canSkipSlice`) + side-effecting applicator
|
|
4
|
-
* (`applySkip`). Both are testable without filesystem mocks (the
|
|
5
|
-
* applicator accepts an injected `readSkipState` / `writeSkipState`
|
|
6
|
-
* pair so the unit tests use in-memory fakes; the production caller
|
|
7
|
-
* passes the real store from `workflow-state-store.ts`).
|
|
8
|
-
*
|
|
9
|
-
* Three rules (per RD §Why + Tech Doc §2-4):
|
|
10
|
-
* - Rule 1 (slice type allowlist): `bugfix` / `feature` / `refactor`
|
|
11
|
-
* can never skip QA, regardless of `--reason`. The allowlist is
|
|
12
|
-
* `['docs', 'config', 'chore']`.
|
|
13
|
-
* - Rule 2 (one-time semantics): if a skip-marker already exists for
|
|
14
|
-
* this rid AND the requested skip is the same → idempotent
|
|
15
|
-
* no-op (`applied: false, idempotent: true`). If different → deny
|
|
16
|
-
* with `reason: "rid already has a different skip applied"`.
|
|
17
|
-
* - Rule 3 (role-based authorization): scripts (caller kind derived
|
|
18
|
-
* from `$PEAKS_CALLER_ID` env var) MUST pass `--i-have-reviewed`
|
|
19
|
-
* in addition to `--reason`.
|
|
20
|
-
*/
|
|
21
1
|
import { type WorkflowSkipState } from './workflow-state-store.js';
|
|
22
2
|
import type { RequestType } from '../artifacts/artifact-prerequisites.js';
|
|
3
|
+
export declare const SKIPPABLE_TYPES: ReadonlyArray<RequestType>;
|
|
23
4
|
export type SkipArgs = {
|
|
24
5
|
/** Request id this skip applies to. */
|
|
25
6
|
rid: string;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* Pure-function classifier (`canSkipSlice`) + side-effecting applicator
|
|
4
|
-
* (`applySkip`). Both are testable without filesystem mocks
|
|
5
|
-
*
|
|
6
|
-
* pair so the unit tests use in-memory fakes; the production caller
|
|
7
|
-
* passes the real store from `workflow-state-store.ts`).
|
|
4
|
+
* (`applySkip`). Both are testable without filesystem mocks: injected
|
|
5
|
+
* read/write state functions, the real store in production.
|
|
8
6
|
*
|
|
9
7
|
* Three rules (per RD §Why + Tech Doc §2-4):
|
|
10
8
|
* - Rule 1 (slice type allowlist): `bugfix` / `feature` / `refactor`
|
|
11
|
-
* can never skip QA
|
|
12
|
-
* `
|
|
13
|
-
* - Rule 2 (one-time semantics):
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* with `reason: "rid already has a different skip applied"`.
|
|
9
|
+
* can never skip QA. The allowlist is DERIVED from the pipeline's
|
|
10
|
+
* QA-free set (`QA_FREE_TYPES`); today that is `docs` / `chore`.
|
|
11
|
+
* - Rule 2 (one-time semantics): the same skip on the same rid is an
|
|
12
|
+
* idempotent no-op (`applied: false`); a different one is denied with
|
|
13
|
+
* `reason: "rid already has a different skip applied"`.
|
|
17
14
|
* - Rule 3 (role-based authorization): scripts (caller kind derived
|
|
18
15
|
* from `$PEAKS_CALLER_ID` env var) MUST pass `--i-have-reviewed`
|
|
19
16
|
* in addition to `--reason`.
|
|
20
17
|
*/
|
|
21
|
-
import {
|
|
18
|
+
import { execFileSync } from 'node:child_process';
|
|
19
|
+
import { userInfo } from 'node:os';
|
|
20
|
+
import { hasControlChars, readSkipState, writeSkipState } from './workflow-state-store.js';
|
|
22
21
|
import { showRequestArtifact } from '../artifacts/request-artifact-service.js';
|
|
23
|
-
|
|
22
|
+
import { QA_FREE_TYPES } from './pipeline-verify-qa-phase.js';
|
|
23
|
+
export const SKIPPABLE_TYPES = QA_FREE_TYPES;
|
|
24
24
|
const SCRIPT_CALLER_IDS = ['ci', 'postinstall', 'cron'];
|
|
25
25
|
/** Parse the `--gates` CLI arg (e.g. "QA,slice-check") into string[]. */
|
|
26
26
|
export function parseGatesList(raw) {
|
|
@@ -53,17 +53,17 @@ export function detectCallerKind(envCallerId) {
|
|
|
53
53
|
*/
|
|
54
54
|
export async function canSkipSlice(projectRoot, sessionId, args, currentState) {
|
|
55
55
|
// Argument validation (no filesystem).
|
|
56
|
-
if (args.reason.trim().length === 0) {
|
|
56
|
+
if (args.reason.trim().length === 0 || hasControlChars(args.reason)) {
|
|
57
57
|
return {
|
|
58
58
|
allowed: false,
|
|
59
|
-
reason: 'skip requires --reason; what is the user-visible justification for this QA bypass?'
|
|
59
|
+
reason: 'skip requires a single-line --reason; what is the user-visible justification for this QA bypass?'
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
const gates = parseGatesList(args.gatesRaw);
|
|
63
|
-
if (gates.length === 0) {
|
|
63
|
+
if (gates.length === 0 || gates.some(hasControlChars)) {
|
|
64
64
|
return {
|
|
65
65
|
allowed: false,
|
|
66
|
-
reason: '--gates must list at least one gate name (e.g. "QA" or "QA,slice-check")'
|
|
66
|
+
reason: '--gates must list at least one single-line gate name (e.g. "QA" or "QA,slice-check")'
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
// Resolve caller kind.
|
|
@@ -94,7 +94,7 @@ export async function canSkipSlice(projectRoot, sessionId, args, currentState) {
|
|
|
94
94
|
if (!SKIPPABLE_TYPES.includes(sliceType)) {
|
|
95
95
|
return {
|
|
96
96
|
allowed: false,
|
|
97
|
-
reason: `slice type "${sliceType}" cannot skip QA (
|
|
97
|
+
reason: `slice type "${sliceType}" cannot skip QA (QA-free types: ${SKIPPABLE_TYPES.join(', ')})`,
|
|
98
98
|
sliceType
|
|
99
99
|
};
|
|
100
100
|
}
|
|
@@ -186,12 +186,10 @@ function pathFromStateFile(projectRoot, sessionId, rid) {
|
|
|
186
186
|
return `${projectRoot}/.peaks/_runtime/${sessionId}/workflow-state/${rid}.json`;
|
|
187
187
|
}
|
|
188
188
|
/** Resolve the author of the skip. Reads `git config --global user.name`
|
|
189
|
-
* synchronously
|
|
190
|
-
*
|
|
189
|
+
* synchronously, falling back to the OS user and then 'unknown'. A value
|
|
190
|
+
* carrying a control character is not written (the reader would refuse it). */
|
|
191
191
|
function resolveSkipAppliedBy() {
|
|
192
192
|
try {
|
|
193
|
-
// Lazy require so the unit tests can stub via process.env.
|
|
194
|
-
const { execFileSync } = require('node:child_process');
|
|
195
193
|
const out = execFileSync('git', ['config', '--global', 'user.name'], {
|
|
196
194
|
encoding: 'utf8',
|
|
197
195
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
@@ -199,7 +197,7 @@ function resolveSkipAppliedBy() {
|
|
|
199
197
|
});
|
|
200
198
|
const trimmed = out.trim();
|
|
201
199
|
if (trimmed.length > 0) {
|
|
202
|
-
return trimmed;
|
|
200
|
+
return hasControlChars(trimmed) ? 'unknown' : trimmed;
|
|
203
201
|
}
|
|
204
202
|
}
|
|
205
203
|
catch {
|
|
@@ -207,9 +205,8 @@ function resolveSkipAppliedBy() {
|
|
|
207
205
|
// fall through
|
|
208
206
|
}
|
|
209
207
|
try {
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
return info.username;
|
|
208
|
+
const info = userInfo();
|
|
209
|
+
return hasControlChars(info.username) ? 'unknown' : info.username;
|
|
213
210
|
}
|
|
214
211
|
catch {
|
|
215
212
|
return 'unknown';
|
|
@@ -6,10 +6,19 @@ export type WorkflowSkipState = {
|
|
|
6
6
|
skipAppliedBy: string;
|
|
7
7
|
callerKind: 'human' | 'llm' | 'script';
|
|
8
8
|
};
|
|
9
|
+
/** C0/C1 controls and DEL. A newline or escape in a printed field is a spoofed line. */
|
|
10
|
+
export declare function hasControlChars(value: string): boolean;
|
|
9
11
|
/**
|
|
10
12
|
* Read the skip-state for a rid, or `null` if no state file exists or
|
|
11
13
|
* the file is malformed. The caller is expected to treat `null` as
|
|
12
14
|
* "no skip applied; evaluate all gates normally".
|
|
15
|
+
*
|
|
16
|
+
* A NULL IS SILENCE, AND SILENCE MEANS "NO SKIP HONOURED". The shape check refuses
|
|
17
|
+
* a record the write path could not have produced — an empty reason, or no gate
|
|
18
|
+
* named — so a hand-planted file that satisfies field PRESENCE but not the write
|
|
19
|
+
* rules lands here as `null` and the gates are evaluated. That is the safe
|
|
20
|
+
* direction: the cost is a skip that stops applying, stated in the RD artifact,
|
|
21
|
+
* not a bypass that starts applying.
|
|
13
22
|
*/
|
|
14
23
|
export declare function readSkipState(projectRoot: string, sessionId: string, rid: string): WorkflowSkipState | null;
|
|
15
24
|
/**
|
|
@@ -21,6 +21,14 @@
|
|
|
21
21
|
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
22
22
|
import { dirname, join } from 'node:path';
|
|
23
23
|
const STATE_FILE_NAME = 'workflow-state.json';
|
|
24
|
+
/** C0/C1 controls and DEL. A newline or escape in a printed field is a spoofed line. */
|
|
25
|
+
export function hasControlChars(value) {
|
|
26
|
+
for (const char of value) {
|
|
27
|
+
if (char < ' ' || char === '\u007f' || (char >= '\u0080' && char <= '\u009f'))
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
24
32
|
function stateFilePath(projectRoot, sessionId, rid) {
|
|
25
33
|
return join(projectRoot, '.peaks', '_runtime', sessionId, 'workflow-state', `${rid}.json`);
|
|
26
34
|
}
|
|
@@ -28,6 +36,13 @@ function stateFilePath(projectRoot, sessionId, rid) {
|
|
|
28
36
|
* Read the skip-state for a rid, or `null` if no state file exists or
|
|
29
37
|
* the file is malformed. The caller is expected to treat `null` as
|
|
30
38
|
* "no skip applied; evaluate all gates normally".
|
|
39
|
+
*
|
|
40
|
+
* A NULL IS SILENCE, AND SILENCE MEANS "NO SKIP HONOURED". The shape check refuses
|
|
41
|
+
* a record the write path could not have produced — an empty reason, or no gate
|
|
42
|
+
* named — so a hand-planted file that satisfies field PRESENCE but not the write
|
|
43
|
+
* rules lands here as `null` and the gates are evaluated. That is the safe
|
|
44
|
+
* direction: the cost is a skip that stops applying, stated in the RD artifact,
|
|
45
|
+
* not a bypass that starts applying.
|
|
31
46
|
*/
|
|
32
47
|
export function readSkipState(projectRoot, sessionId, rid) {
|
|
33
48
|
const path = stateFilePath(projectRoot, sessionId, rid);
|
|
@@ -81,14 +96,24 @@ function isWorkflowSkipState(value) {
|
|
|
81
96
|
return false;
|
|
82
97
|
if (!Array.isArray(v.skippedGates))
|
|
83
98
|
return false;
|
|
84
|
-
if (
|
|
99
|
+
if (v.skippedGates.length === 0)
|
|
100
|
+
return false;
|
|
101
|
+
if (!v.skippedGates.every((g) => typeof g === 'string' && g.trim().length > 0 && g === g.trim() && !hasControlChars(g)))
|
|
85
102
|
return false;
|
|
86
103
|
if (typeof v.skipReason !== 'string')
|
|
87
104
|
return false;
|
|
105
|
+
if (v.skipReason.trim().length === 0)
|
|
106
|
+
return false;
|
|
107
|
+
if (hasControlChars(v.skipReason))
|
|
108
|
+
return false;
|
|
88
109
|
if (typeof v.skipAppliedAt !== 'string')
|
|
89
110
|
return false;
|
|
111
|
+
if (hasControlChars(v.skipAppliedAt))
|
|
112
|
+
return false;
|
|
90
113
|
if (typeof v.skipAppliedBy !== 'string')
|
|
91
114
|
return false;
|
|
115
|
+
if (hasControlChars(v.skipAppliedBy))
|
|
116
|
+
return false;
|
|
92
117
|
if (v.callerKind !== 'human' && v.callerKind !== 'llm' && v.callerKind !== 'script')
|
|
93
118
|
return false;
|
|
94
119
|
return true;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `claude-settings-retirements.ts` — the `hooks.PreToolUse` entries this template
|
|
3
|
+
* used to declare and has since RETIRED, plus the shape predicate the retirement
|
|
4
|
+
* is tested against.
|
|
5
|
+
*
|
|
6
|
+
* WHY A RETIREMENT IS NOT A DELETION. `mergeTemplateOwnedHooks` (in
|
|
7
|
+
* `claude-settings-template-merge.ts`) carries across every on-disk entry the
|
|
8
|
+
* template does not declare — that is the whole point of the entry-level
|
|
9
|
+
* ownership rule, and it is what keeps `installAutoCompactHook`'s `Bash|Task`
|
|
10
|
+
* entry alive across an init. So simply STOPPING the emission reaches nobody: an
|
|
11
|
+
* install written by an earlier release keeps the entry forever. Declaring less
|
|
12
|
+
* cannot retire an entry; something has to say "this one is gone", and
|
|
13
|
+
* `isRetiredTemplateEntry` is that something. `templateContentMatches` calls it
|
|
14
|
+
* too, because a file still carrying a retired entry has to compare as DRIFTED or
|
|
15
|
+
* the merge that would drop it never runs.
|
|
16
|
+
*
|
|
17
|
+
* Extracted from `claude-settings-template-merge.ts` when the second retirement
|
|
18
|
+
* pushed that module past the 300-line cap. The bodies moved verbatim; the
|
|
19
|
+
* predicate and its two shape types came along because the predicate is their
|
|
20
|
+
* only reader inside that module.
|
|
21
|
+
*
|
|
22
|
+
* TWO RETIREMENTS SO FAR:
|
|
23
|
+
* - TEMPLATE_VERSION 1.8.0 — the `Write|Edit|MultiEdit` gate handler;
|
|
24
|
+
* - TEMPLATE_VERSION 1.10.0 — the two layer-B feedback hooks.
|
|
25
|
+
* They share neither a matcher nor a command form, so each gets its own narrow
|
|
26
|
+
* predicate rather than one looser rule. The narrowness is load-bearing: a
|
|
27
|
+
* predicate that dropped "anything on this matcher" would delete a USER's hook,
|
|
28
|
+
* which is the failure the ownership rule exists to prevent.
|
|
29
|
+
*/
|
|
30
|
+
/** One handler in a `hooks.PreToolUse` entry, in the shape this template declares. */
|
|
31
|
+
export type TemplateHookCommand = {
|
|
32
|
+
type: string;
|
|
33
|
+
command: string;
|
|
34
|
+
shell?: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* One `hooks.PreToolUse` entry in the shape this template declares. The
|
|
38
|
+
* `matcher` + `hooks` pair is the entry's identity everywhere in this concern:
|
|
39
|
+
* `matcher` alone is not unique (two `Bash` entries), and whole-object identity
|
|
40
|
+
* would make a hand-edited entry unrecognizable and therefore unrepairable.
|
|
41
|
+
*/
|
|
42
|
+
export type TemplatePreToolUseEntry = {
|
|
43
|
+
matcher: string;
|
|
44
|
+
hooks: TemplateHookCommand[];
|
|
45
|
+
};
|
|
46
|
+
export declare function isPreToolUseEntry(value: unknown): value is TemplatePreToolUseEntry;
|
|
47
|
+
/**
|
|
48
|
+
* Is `entry` one this template used to declare and has since RETIRED?
|
|
49
|
+
*
|
|
50
|
+
* Each retirement gets its own narrow predicate — the shapes share neither a
|
|
51
|
+
* matcher nor a command form. An entry whose shape matches nothing here is not
|
|
52
|
+
* retired, and is preserved.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isRetiredTemplateEntry(entry: unknown): boolean;
|