@lumenflow/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/README.md +119 -0
- package/dist/active-wu-detector.d.ts +33 -0
- package/dist/active-wu-detector.js +106 -0
- package/dist/adapters/filesystem-metrics.adapter.d.ts +108 -0
- package/dist/adapters/filesystem-metrics.adapter.js +519 -0
- package/dist/adapters/terminal-renderer.adapter.d.ts +106 -0
- package/dist/adapters/terminal-renderer.adapter.js +337 -0
- package/dist/arg-parser.d.ts +63 -0
- package/dist/arg-parser.js +560 -0
- package/dist/backlog-editor.d.ts +98 -0
- package/dist/backlog-editor.js +179 -0
- package/dist/backlog-generator.d.ts +111 -0
- package/dist/backlog-generator.js +381 -0
- package/dist/backlog-parser.d.ts +45 -0
- package/dist/backlog-parser.js +102 -0
- package/dist/backlog-sync-validator.d.ts +78 -0
- package/dist/backlog-sync-validator.js +294 -0
- package/dist/branch-drift.d.ts +34 -0
- package/dist/branch-drift.js +51 -0
- package/dist/cleanup-install-config.d.ts +33 -0
- package/dist/cleanup-install-config.js +37 -0
- package/dist/cleanup-lock.d.ts +139 -0
- package/dist/cleanup-lock.js +313 -0
- package/dist/code-path-validator.d.ts +146 -0
- package/dist/code-path-validator.js +537 -0
- package/dist/code-paths-overlap.d.ts +55 -0
- package/dist/code-paths-overlap.js +245 -0
- package/dist/commands-logger.d.ts +77 -0
- package/dist/commands-logger.js +254 -0
- package/dist/commit-message-utils.d.ts +25 -0
- package/dist/commit-message-utils.js +41 -0
- package/dist/compliance-parser.d.ts +150 -0
- package/dist/compliance-parser.js +507 -0
- package/dist/constants/backlog-patterns.d.ts +20 -0
- package/dist/constants/backlog-patterns.js +23 -0
- package/dist/constants/dora-constants.d.ts +49 -0
- package/dist/constants/dora-constants.js +53 -0
- package/dist/constants/gate-constants.d.ts +15 -0
- package/dist/constants/gate-constants.js +15 -0
- package/dist/constants/linter-constants.d.ts +16 -0
- package/dist/constants/linter-constants.js +16 -0
- package/dist/constants/tokenizer-constants.d.ts +15 -0
- package/dist/constants/tokenizer-constants.js +15 -0
- package/dist/core/scope-checker.d.ts +97 -0
- package/dist/core/scope-checker.js +163 -0
- package/dist/core/tool-runner.d.ts +161 -0
- package/dist/core/tool-runner.js +393 -0
- package/dist/core/tool.constants.d.ts +105 -0
- package/dist/core/tool.constants.js +101 -0
- package/dist/core/tool.schemas.d.ts +226 -0
- package/dist/core/tool.schemas.js +226 -0
- package/dist/core/worktree-guard.d.ts +130 -0
- package/dist/core/worktree-guard.js +242 -0
- package/dist/coverage-gate.d.ts +108 -0
- package/dist/coverage-gate.js +196 -0
- package/dist/date-utils.d.ts +75 -0
- package/dist/date-utils.js +140 -0
- package/dist/dependency-graph.d.ts +142 -0
- package/dist/dependency-graph.js +550 -0
- package/dist/dependency-guard.d.ts +54 -0
- package/dist/dependency-guard.js +142 -0
- package/dist/dependency-validator.d.ts +105 -0
- package/dist/dependency-validator.js +154 -0
- package/dist/docs-path-validator.d.ts +36 -0
- package/dist/docs-path-validator.js +95 -0
- package/dist/domain/orchestration.constants.d.ts +99 -0
- package/dist/domain/orchestration.constants.js +97 -0
- package/dist/domain/orchestration.schemas.d.ts +280 -0
- package/dist/domain/orchestration.schemas.js +211 -0
- package/dist/domain/orchestration.types.d.ts +133 -0
- package/dist/domain/orchestration.types.js +12 -0
- package/dist/error-handler.d.ts +116 -0
- package/dist/error-handler.js +136 -0
- package/dist/file-classifiers.d.ts +62 -0
- package/dist/file-classifiers.js +108 -0
- package/dist/gates-agent-mode.d.ts +81 -0
- package/dist/gates-agent-mode.js +94 -0
- package/dist/generate-traceability.d.ts +107 -0
- package/dist/generate-traceability.js +411 -0
- package/dist/git-adapter.d.ts +395 -0
- package/dist/git-adapter.js +649 -0
- package/dist/git-staged-validator.d.ts +32 -0
- package/dist/git-staged-validator.js +48 -0
- package/dist/hardcoded-strings.d.ts +61 -0
- package/dist/hardcoded-strings.js +270 -0
- package/dist/incremental-lint.d.ts +78 -0
- package/dist/incremental-lint.js +129 -0
- package/dist/incremental-test.d.ts +39 -0
- package/dist/incremental-test.js +61 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +61 -0
- package/dist/invariants/check-automated-tests.d.ts +50 -0
- package/dist/invariants/check-automated-tests.js +166 -0
- package/dist/invariants-runner.d.ts +103 -0
- package/dist/invariants-runner.js +527 -0
- package/dist/lane-checker.d.ts +50 -0
- package/dist/lane-checker.js +319 -0
- package/dist/lane-inference.d.ts +39 -0
- package/dist/lane-inference.js +195 -0
- package/dist/lane-lock.d.ts +211 -0
- package/dist/lane-lock.js +474 -0
- package/dist/lane-validator.d.ts +48 -0
- package/dist/lane-validator.js +114 -0
- package/dist/logs-lib.d.ts +104 -0
- package/dist/logs-lib.js +207 -0
- package/dist/lumenflow-config-schema.d.ts +272 -0
- package/dist/lumenflow-config-schema.js +207 -0
- package/dist/lumenflow-config.d.ts +95 -0
- package/dist/lumenflow-config.js +236 -0
- package/dist/manual-test-validator.d.ts +80 -0
- package/dist/manual-test-validator.js +200 -0
- package/dist/merge-lock.d.ts +115 -0
- package/dist/merge-lock.js +251 -0
- package/dist/micro-worktree.d.ts +159 -0
- package/dist/micro-worktree.js +427 -0
- package/dist/migration-deployer.d.ts +69 -0
- package/dist/migration-deployer.js +151 -0
- package/dist/orchestration-advisory-loader.d.ts +28 -0
- package/dist/orchestration-advisory-loader.js +87 -0
- package/dist/orchestration-advisory.d.ts +58 -0
- package/dist/orchestration-advisory.js +94 -0
- package/dist/orchestration-di.d.ts +48 -0
- package/dist/orchestration-di.js +57 -0
- package/dist/orchestration-rules.d.ts +57 -0
- package/dist/orchestration-rules.js +201 -0
- package/dist/orphan-detector.d.ts +131 -0
- package/dist/orphan-detector.js +226 -0
- package/dist/path-classifiers.d.ts +57 -0
- package/dist/path-classifiers.js +93 -0
- package/dist/piped-command-detector.d.ts +34 -0
- package/dist/piped-command-detector.js +64 -0
- package/dist/ports/dashboard-renderer.port.d.ts +112 -0
- package/dist/ports/dashboard-renderer.port.js +25 -0
- package/dist/ports/metrics-collector.port.d.ts +132 -0
- package/dist/ports/metrics-collector.port.js +26 -0
- package/dist/process-detector.d.ts +84 -0
- package/dist/process-detector.js +172 -0
- package/dist/prompt-linter.d.ts +72 -0
- package/dist/prompt-linter.js +312 -0
- package/dist/prompt-monitor.d.ts +15 -0
- package/dist/prompt-monitor.js +205 -0
- package/dist/rebase-artifact-cleanup.d.ts +145 -0
- package/dist/rebase-artifact-cleanup.js +433 -0
- package/dist/retry-strategy.d.ts +189 -0
- package/dist/retry-strategy.js +283 -0
- package/dist/risk-detector.d.ts +108 -0
- package/dist/risk-detector.js +252 -0
- package/dist/rollback-utils.d.ts +76 -0
- package/dist/rollback-utils.js +104 -0
- package/dist/section-headings.d.ts +43 -0
- package/dist/section-headings.js +49 -0
- package/dist/spawn-escalation.d.ts +90 -0
- package/dist/spawn-escalation.js +253 -0
- package/dist/spawn-monitor.d.ts +229 -0
- package/dist/spawn-monitor.js +672 -0
- package/dist/spawn-recovery.d.ts +82 -0
- package/dist/spawn-recovery.js +298 -0
- package/dist/spawn-registry-schema.d.ts +98 -0
- package/dist/spawn-registry-schema.js +108 -0
- package/dist/spawn-registry-store.d.ts +146 -0
- package/dist/spawn-registry-store.js +273 -0
- package/dist/spawn-tree.d.ts +121 -0
- package/dist/spawn-tree.js +285 -0
- package/dist/stamp-status-validator.d.ts +84 -0
- package/dist/stamp-status-validator.js +134 -0
- package/dist/stamp-utils.d.ts +100 -0
- package/dist/stamp-utils.js +229 -0
- package/dist/state-machine.d.ts +26 -0
- package/dist/state-machine.js +83 -0
- package/dist/system-map-validator.d.ts +80 -0
- package/dist/system-map-validator.js +272 -0
- package/dist/telemetry.d.ts +80 -0
- package/dist/telemetry.js +213 -0
- package/dist/token-counter.d.ts +51 -0
- package/dist/token-counter.js +145 -0
- package/dist/usecases/get-dashboard-data.usecase.d.ts +52 -0
- package/dist/usecases/get-dashboard-data.usecase.js +61 -0
- package/dist/usecases/get-suggestions.usecase.d.ts +100 -0
- package/dist/usecases/get-suggestions.usecase.js +153 -0
- package/dist/user-normalizer.d.ts +41 -0
- package/dist/user-normalizer.js +141 -0
- package/dist/validators/phi-constants.d.ts +97 -0
- package/dist/validators/phi-constants.js +152 -0
- package/dist/validators/phi-scanner.d.ts +58 -0
- package/dist/validators/phi-scanner.js +215 -0
- package/dist/worktree-ownership.d.ts +50 -0
- package/dist/worktree-ownership.js +74 -0
- package/dist/worktree-scanner.d.ts +103 -0
- package/dist/worktree-scanner.js +168 -0
- package/dist/worktree-symlink.d.ts +99 -0
- package/dist/worktree-symlink.js +359 -0
- package/dist/wu-backlog-updater.d.ts +17 -0
- package/dist/wu-backlog-updater.js +37 -0
- package/dist/wu-checkpoint.d.ts +124 -0
- package/dist/wu-checkpoint.js +233 -0
- package/dist/wu-claim-helpers.d.ts +26 -0
- package/dist/wu-claim-helpers.js +63 -0
- package/dist/wu-claim-resume.d.ts +106 -0
- package/dist/wu-claim-resume.js +276 -0
- package/dist/wu-consistency-checker.d.ts +95 -0
- package/dist/wu-consistency-checker.js +567 -0
- package/dist/wu-constants.d.ts +1275 -0
- package/dist/wu-constants.js +1382 -0
- package/dist/wu-create-validators.d.ts +42 -0
- package/dist/wu-create-validators.js +93 -0
- package/dist/wu-done-branch-only.d.ts +63 -0
- package/dist/wu-done-branch-only.js +191 -0
- package/dist/wu-done-messages.d.ts +119 -0
- package/dist/wu-done-messages.js +185 -0
- package/dist/wu-done-pr.d.ts +72 -0
- package/dist/wu-done-pr.js +174 -0
- package/dist/wu-done-retry-helpers.d.ts +85 -0
- package/dist/wu-done-retry-helpers.js +172 -0
- package/dist/wu-done-ui.d.ts +37 -0
- package/dist/wu-done-ui.js +69 -0
- package/dist/wu-done-validators.d.ts +411 -0
- package/dist/wu-done-validators.js +1229 -0
- package/dist/wu-done-worktree.d.ts +182 -0
- package/dist/wu-done-worktree.js +1097 -0
- package/dist/wu-helpers.d.ts +128 -0
- package/dist/wu-helpers.js +248 -0
- package/dist/wu-lint.d.ts +70 -0
- package/dist/wu-lint.js +234 -0
- package/dist/wu-paths.d.ts +171 -0
- package/dist/wu-paths.js +178 -0
- package/dist/wu-preflight-validators.d.ts +86 -0
- package/dist/wu-preflight-validators.js +251 -0
- package/dist/wu-recovery.d.ts +138 -0
- package/dist/wu-recovery.js +341 -0
- package/dist/wu-repair-core.d.ts +131 -0
- package/dist/wu-repair-core.js +669 -0
- package/dist/wu-schema-normalization.d.ts +17 -0
- package/dist/wu-schema-normalization.js +82 -0
- package/dist/wu-schema.d.ts +793 -0
- package/dist/wu-schema.js +881 -0
- package/dist/wu-spawn-helpers.d.ts +121 -0
- package/dist/wu-spawn-helpers.js +271 -0
- package/dist/wu-spawn.d.ts +158 -0
- package/dist/wu-spawn.js +1306 -0
- package/dist/wu-state-schema.d.ts +213 -0
- package/dist/wu-state-schema.js +156 -0
- package/dist/wu-state-store.d.ts +264 -0
- package/dist/wu-state-store.js +691 -0
- package/dist/wu-status-transition.d.ts +63 -0
- package/dist/wu-status-transition.js +382 -0
- package/dist/wu-status-updater.d.ts +25 -0
- package/dist/wu-status-updater.js +116 -0
- package/dist/wu-transaction-collectors.d.ts +116 -0
- package/dist/wu-transaction-collectors.js +272 -0
- package/dist/wu-transaction.d.ts +170 -0
- package/dist/wu-transaction.js +273 -0
- package/dist/wu-validation-constants.d.ts +60 -0
- package/dist/wu-validation-constants.js +66 -0
- package/dist/wu-validation.d.ts +118 -0
- package/dist/wu-validation.js +243 -0
- package/dist/wu-validator.d.ts +62 -0
- package/dist/wu-validator.js +325 -0
- package/dist/wu-yaml-fixer.d.ts +97 -0
- package/dist/wu-yaml-fixer.js +264 -0
- package/dist/wu-yaml.d.ts +86 -0
- package/dist/wu-yaml.js +222 -0
- package/package.json +114 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WU-1584: Retry and recovery helpers for wu:done
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - Squashing duplicate completion commits from retry attempts
|
|
6
|
+
* - Detecting and counting previous completion attempts
|
|
7
|
+
* - Preparing zombie recovery with squash
|
|
8
|
+
* - Handling parallel completions with auto-rebase
|
|
9
|
+
*
|
|
10
|
+
* @module wu-done-retry-helpers
|
|
11
|
+
*/
|
|
12
|
+
import { LOG_PREFIX, EMOJI, GIT, GIT_COMMANDS, GIT_FLAGS, GIT_REFS, STRING_LITERALS, } from './wu-constants.js';
|
|
13
|
+
import { createError, ErrorCodes } from './error-handler.js';
|
|
14
|
+
/**
|
|
15
|
+
* Regex to match wu:done completion commit messages
|
|
16
|
+
* Format: wu(<id>): done - <title>
|
|
17
|
+
*
|
|
18
|
+
* Note: Does not use ^ anchor to allow matching within git log --oneline output
|
|
19
|
+
* which includes commit hash prefix: "abc1234 wu(wu-500): done - title"
|
|
20
|
+
*
|
|
21
|
+
* @constant {RegExp}
|
|
22
|
+
*/
|
|
23
|
+
const COMPLETION_COMMIT_PATTERN = /wu\(([^)]+)\):\s*done\s*-/i;
|
|
24
|
+
/**
|
|
25
|
+
* Count previous completion attempt commits for a WU on the current branch
|
|
26
|
+
*
|
|
27
|
+
* WU-1584 Fix #1: Detect duplicate commits from retries
|
|
28
|
+
*
|
|
29
|
+
* Searches commit history for commits matching the completion pattern
|
|
30
|
+
* for the specified WU ID.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} wuId - WU ID (e.g., 'WU-1584')
|
|
33
|
+
* @param {object} gitAdapter - Git adapter instance
|
|
34
|
+
* @returns {Promise<number>} Number of completion attempt commits found
|
|
35
|
+
*/
|
|
36
|
+
export async function countPreviousCompletionAttempts(wuId, gitAdapter) {
|
|
37
|
+
const normalizedId = wuId.toLowerCase();
|
|
38
|
+
try {
|
|
39
|
+
// Get recent commit history (limit to reasonable amount)
|
|
40
|
+
const log = await gitAdapter.log({ maxCount: GIT.LOG_MAX_COUNT });
|
|
41
|
+
if (!log || !log.all) {
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
// Count trailing completion attempts on the branch tip only.
|
|
45
|
+
// This avoids accidentally squashing unrelated commits if the history contains
|
|
46
|
+
// older completion commits that are not part of the current retry chain.
|
|
47
|
+
let trailingCount = 0;
|
|
48
|
+
for (const commit of log.all) {
|
|
49
|
+
const match = commit.message.match(COMPLETION_COMMIT_PATTERN);
|
|
50
|
+
if (!match)
|
|
51
|
+
break;
|
|
52
|
+
const commitWuId = match[1].toLowerCase();
|
|
53
|
+
if (commitWuId !== normalizedId)
|
|
54
|
+
break;
|
|
55
|
+
trailingCount += 1;
|
|
56
|
+
}
|
|
57
|
+
return trailingCount;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.warn(`${LOG_PREFIX.DONE} ${EMOJI.WARNING} Could not count previous attempts: ${error.message}`);
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export async function squashPreviousCompletionAttempts(wuId, count, gitAdapter, options = {}) {
|
|
65
|
+
const { preserveIndex = true } = options;
|
|
66
|
+
if (count === 0) {
|
|
67
|
+
return { squashed: false, count: 0 };
|
|
68
|
+
}
|
|
69
|
+
console.log(`${LOG_PREFIX.DONE} ${EMOJI.WARNING} Detected ${count} previous completion attempt commit(s)`);
|
|
70
|
+
console.log(`${LOG_PREFIX.DONE} ${EMOJI.INFO} Squashing previous attempts to avoid duplicate commits...`);
|
|
71
|
+
try {
|
|
72
|
+
// In the normal retry flow we need to preserve the staged metadata transaction,
|
|
73
|
+
// so we use --soft (index/working tree unchanged).
|
|
74
|
+
//
|
|
75
|
+
// In zombie recovery we want to drop prior completion commits cleanly and start
|
|
76
|
+
// from a known-good state, so we use --hard (index/working tree reset).
|
|
77
|
+
if (!preserveIndex) {
|
|
78
|
+
const status = (await gitAdapter.getStatus())?.trim?.() ?? '';
|
|
79
|
+
if (status) {
|
|
80
|
+
throw createError(ErrorCodes.RECOVERY_ERROR, `Cannot squash previous attempts: worktree has uncommitted changes.${STRING_LITERALS.NEWLINE}${STRING_LITERALS.NEWLINE}` +
|
|
81
|
+
`Fix: In your worktree, run:${STRING_LITERALS.NEWLINE}` +
|
|
82
|
+
` ${GIT_COMMANDS.GIT} status${STRING_LITERALS.NEWLINE}` +
|
|
83
|
+
` ${GIT_COMMANDS.GIT} restore -SW .${STRING_LITERALS.NEWLINE}` +
|
|
84
|
+
`Then retry wu:done.${STRING_LITERALS.NEWLINE}`, { wuId, count, preserveIndex, status });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const resetMode = preserveIndex ? GIT_FLAGS.SOFT : GIT_FLAGS.HARD;
|
|
88
|
+
const headBackRef = `${GIT_REFS.HEAD}~${count}`;
|
|
89
|
+
await gitAdapter.raw([GIT_COMMANDS.RESET, resetMode, headBackRef]);
|
|
90
|
+
console.log(`${LOG_PREFIX.DONE} ${EMOJI.SUCCESS} Squashed ${count} previous attempt(s) - will create single completion commit`);
|
|
91
|
+
return { squashed: true, count };
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
console.warn(`${LOG_PREFIX.DONE} ${EMOJI.WARNING} Could not squash previous attempts: ${error.message}`);
|
|
95
|
+
return { squashed: false, count: 0 };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Prepare zombie recovery with squash of previous attempts
|
|
100
|
+
*
|
|
101
|
+
* WU-1584 Fix #2: Recovery loop should squash previous attempt commits
|
|
102
|
+
*
|
|
103
|
+
* When recovering from zombie state (status=done but worktree exists),
|
|
104
|
+
* first squash any previous completion attempts to avoid "rebase hell".
|
|
105
|
+
*
|
|
106
|
+
* @param {string} wuId - WU ID
|
|
107
|
+
* @param {object} gitAdapter - Git adapter instance
|
|
108
|
+
* @returns {Promise<{ squashedCount: number }>} Result
|
|
109
|
+
*/
|
|
110
|
+
export async function prepareRecoveryWithSquash(wuId, gitAdapter) {
|
|
111
|
+
console.log(`${LOG_PREFIX.DONE} ${EMOJI.INFO} Checking for previous completion attempts before recovery...`);
|
|
112
|
+
const previousCount = await countPreviousCompletionAttempts(wuId, gitAdapter);
|
|
113
|
+
if (previousCount > 0) {
|
|
114
|
+
console.log(`${LOG_PREFIX.DONE} Squashing ${previousCount} previous completion attempt(s) for clean recovery`);
|
|
115
|
+
// Recovery: do not preserve index; reset to a clean state before continuing.
|
|
116
|
+
const result = await squashPreviousCompletionAttempts(wuId, previousCount, gitAdapter, {
|
|
117
|
+
preserveIndex: false,
|
|
118
|
+
});
|
|
119
|
+
return { squashedCount: result.squashed ? result.count : 0 };
|
|
120
|
+
}
|
|
121
|
+
return { squashedCount: 0 };
|
|
122
|
+
}
|
|
123
|
+
export async function handleParallelCompletions(wuId, doc, gitAdapter, options = {}) {
|
|
124
|
+
const { worktreePath, autoRebase = true } = options;
|
|
125
|
+
// Fetch latest from origin
|
|
126
|
+
await gitAdapter.fetch();
|
|
127
|
+
// Get current origin/main SHA
|
|
128
|
+
const currentMainSha = await gitAdapter.getCommitHash('origin/main');
|
|
129
|
+
// Get baseline SHA from when WU was claimed
|
|
130
|
+
const baselineSha = doc.baseline_main_sha;
|
|
131
|
+
if (!baselineSha || currentMainSha === baselineSha) {
|
|
132
|
+
// No parallel completions - main hasn't changed since claim
|
|
133
|
+
return { parallelDetected: false, rebaseTriggered: false };
|
|
134
|
+
}
|
|
135
|
+
// Check if changes since baseline include other WU completions
|
|
136
|
+
const newCommits = await gitAdapter.raw([
|
|
137
|
+
'log',
|
|
138
|
+
'--oneline',
|
|
139
|
+
`${baselineSha}..origin/main`,
|
|
140
|
+
'--',
|
|
141
|
+
]);
|
|
142
|
+
const hasParallelCompletions = newCommits && newCommits.trim() && COMPLETION_COMMIT_PATTERN.test(newCommits);
|
|
143
|
+
if (!hasParallelCompletions) {
|
|
144
|
+
// Changes exist but are not WU completions - proceed normally
|
|
145
|
+
return { parallelDetected: false, rebaseTriggered: false };
|
|
146
|
+
}
|
|
147
|
+
// Parallel completions detected
|
|
148
|
+
console.log(`${LOG_PREFIX.DONE} ${EMOJI.WARNING} Parallel completion(s) detected on main since WU claim`);
|
|
149
|
+
if (!autoRebase) {
|
|
150
|
+
throw createError(ErrorCodes.VALIDATION_ERROR, `Parallel completions detected on main since ${wuId} was claimed.\n` +
|
|
151
|
+
`This would cause merge conflicts during wu:done.\n\n` +
|
|
152
|
+
`Fix: Run 'git fetch origin && git rebase origin/main' in your worktree,\n` +
|
|
153
|
+
`then retry wu:done.\n\n` +
|
|
154
|
+
`Or use --no-auto-rebase to disable this check (not recommended).`, { wuId, baselineSha, currentMainSha });
|
|
155
|
+
}
|
|
156
|
+
// Trigger auto-rebase
|
|
157
|
+
console.log(`${LOG_PREFIX.DONE} ${EMOJI.INFO} Triggering auto-rebase to incorporate parallel completions...`);
|
|
158
|
+
try {
|
|
159
|
+
// Rebase the current branch onto origin/main
|
|
160
|
+
await gitAdapter.rebase('origin/main');
|
|
161
|
+
console.log(`${LOG_PREFIX.DONE} ${EMOJI.SUCCESS} Auto-rebase complete - parallel completions incorporated`);
|
|
162
|
+
return { parallelDetected: true, rebaseTriggered: true };
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
throw createError(ErrorCodes.GIT_ERROR, `Auto-rebase failed: ${error.message}\n\n` +
|
|
166
|
+
`Manual resolution required:\n` +
|
|
167
|
+
`1. cd ${worktreePath || 'your-worktree'}\n` +
|
|
168
|
+
`2. git fetch origin && git rebase origin/main\n` +
|
|
169
|
+
`3. Resolve conflicts if any\n` +
|
|
170
|
+
`4. Retry wu:done`, { wuId, originalError: error.message });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WU Done UI Helpers
|
|
3
|
+
*
|
|
4
|
+
* WU-1281: Extracted display helpers to consolidate DRY violations
|
|
5
|
+
* and use library-first duration formatting.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link tools/wu-done.mjs} - Primary consumer
|
|
8
|
+
* @see {@link tools/lib/wu-constants.mjs} - UI constants
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Print prominent gate failure box
|
|
12
|
+
*
|
|
13
|
+
* Consolidated from two duplicate implementations in wu-done.mjs
|
|
14
|
+
* (worktree mode and branch-only mode). Uses pretty-ms for
|
|
15
|
+
* human-readable duration formatting.
|
|
16
|
+
*
|
|
17
|
+
* @param {object} options - Failure info
|
|
18
|
+
* @param {string} options.id - WU ID (e.g., 'WU-123')
|
|
19
|
+
* @param {string} options.location - Location description (worktree path or 'Branch-Only')
|
|
20
|
+
* @param {number} options.durationMs - Duration in milliseconds
|
|
21
|
+
* @param {boolean} [options.isWorktreeMode=true] - True for worktree mode, false for branch-only
|
|
22
|
+
*/
|
|
23
|
+
export declare function printGateFailureBox({ id, location, durationMs, isWorktreeMode }: {
|
|
24
|
+
id: any;
|
|
25
|
+
location: any;
|
|
26
|
+
durationMs: any;
|
|
27
|
+
isWorktreeMode?: boolean;
|
|
28
|
+
}): void;
|
|
29
|
+
/**
|
|
30
|
+
* Print git status preview with truncation
|
|
31
|
+
*
|
|
32
|
+
* Shows first N lines of git status output with indication
|
|
33
|
+
* of how many more files exist. Parses output once (not three times).
|
|
34
|
+
*
|
|
35
|
+
* @param {string} statusOutput - Raw git status --porcelain output
|
|
36
|
+
*/
|
|
37
|
+
export declare function printStatusPreview(statusOutput: any): void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WU Done UI Helpers
|
|
3
|
+
*
|
|
4
|
+
* WU-1281: Extracted display helpers to consolidate DRY violations
|
|
5
|
+
* and use library-first duration formatting.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link tools/wu-done.mjs} - Primary consumer
|
|
8
|
+
* @see {@link tools/lib/wu-constants.mjs} - UI constants
|
|
9
|
+
*/
|
|
10
|
+
import prettyMs from 'pretty-ms';
|
|
11
|
+
import { UI, LOG_PREFIX, STRING_LITERALS } from './wu-constants.js';
|
|
12
|
+
/**
|
|
13
|
+
* Print prominent gate failure box
|
|
14
|
+
*
|
|
15
|
+
* Consolidated from two duplicate implementations in wu-done.mjs
|
|
16
|
+
* (worktree mode and branch-only mode). Uses pretty-ms for
|
|
17
|
+
* human-readable duration formatting.
|
|
18
|
+
*
|
|
19
|
+
* @param {object} options - Failure info
|
|
20
|
+
* @param {string} options.id - WU ID (e.g., 'WU-123')
|
|
21
|
+
* @param {string} options.location - Location description (worktree path or 'Branch-Only')
|
|
22
|
+
* @param {number} options.durationMs - Duration in milliseconds
|
|
23
|
+
* @param {boolean} [options.isWorktreeMode=true] - True for worktree mode, false for branch-only
|
|
24
|
+
*/
|
|
25
|
+
export function printGateFailureBox({ id, location, durationMs, isWorktreeMode = true }) {
|
|
26
|
+
const width = UI.ERROR_BOX_WIDTH;
|
|
27
|
+
const duration = prettyMs(durationMs, { secondsDecimalDigits: 0 });
|
|
28
|
+
console.error(`\n${'═'.repeat(width)}`);
|
|
29
|
+
console.error('❌ WU:DONE FAILED - GATES DID NOT PASS');
|
|
30
|
+
console.error('═'.repeat(width));
|
|
31
|
+
console.error(`WU ID: ${id}`);
|
|
32
|
+
console.error(`${isWorktreeMode ? 'Worktree' : 'Mode'}: ${isWorktreeMode ? location : 'Branch-Only'}`);
|
|
33
|
+
console.error(`Duration: ${duration}`);
|
|
34
|
+
console.error('─'.repeat(width));
|
|
35
|
+
console.error('Next steps:');
|
|
36
|
+
if (isWorktreeMode) {
|
|
37
|
+
console.error(` 1. cd ${location}`);
|
|
38
|
+
console.error(' 2. Review gate output above to identify failures');
|
|
39
|
+
console.error(' 3. Fix issues in the worktree');
|
|
40
|
+
console.error(' 4. Run: pnpm gates');
|
|
41
|
+
console.error(` 5. cd back to main and re-run: pnpm wu:done --id ${id}`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
console.error(' 1. Review gate output above to identify failures');
|
|
45
|
+
console.error(' 2. Fix issues on the lane branch');
|
|
46
|
+
console.error(' 3. Run: pnpm gates');
|
|
47
|
+
console.error(` 4. Re-run: pnpm wu:done --id ${id}`);
|
|
48
|
+
}
|
|
49
|
+
console.error(`${'═'.repeat(width)}\n`);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Print git status preview with truncation
|
|
53
|
+
*
|
|
54
|
+
* Shows first N lines of git status output with indication
|
|
55
|
+
* of how many more files exist. Parses output once (not three times).
|
|
56
|
+
*
|
|
57
|
+
* @param {string} statusOutput - Raw git status --porcelain output
|
|
58
|
+
*/
|
|
59
|
+
export function printStatusPreview(statusOutput) {
|
|
60
|
+
const lines = statusOutput.split(STRING_LITERALS.NEWLINE).filter((line) => line.trim());
|
|
61
|
+
const previewLimit = UI.STATUS_PREVIEW_LINES;
|
|
62
|
+
const preview = lines.slice(0, previewLimit);
|
|
63
|
+
console.warn(`${LOG_PREFIX.DONE} ⚠️ Working tree still has changes after rollback:`);
|
|
64
|
+
console.warn(preview.join(STRING_LITERALS.NEWLINE));
|
|
65
|
+
if (lines.length > previewLimit) {
|
|
66
|
+
console.warn(` ... and ${lines.length - previewLimit} more files`);
|
|
67
|
+
}
|
|
68
|
+
console.warn(`${LOG_PREFIX.DONE} Run "git status" for full details`);
|
|
69
|
+
}
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Validation functions for wu:done workflow
|
|
4
|
+
* Extracted from wu-done.mjs (WU-1215 refactoring)
|
|
5
|
+
*/
|
|
6
|
+
import { execSync as execSyncImport } from 'node:child_process';
|
|
7
|
+
import { validateAutomatedTestRequirement } from './manual-test-validator.js';
|
|
8
|
+
import { validatePreflight } from './wu-preflight-validators.js';
|
|
9
|
+
/**
|
|
10
|
+
* Validates command-line inputs and WU ID format
|
|
11
|
+
* @param {string[]} argv - Process arguments
|
|
12
|
+
* @returns {{ args: object, id: string }} Parsed args and validated WU ID
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateInputs(argv: any): {
|
|
15
|
+
args: import("commander").OptionValues;
|
|
16
|
+
id: any;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Read WU YAML preferring worktree version over main version
|
|
20
|
+
*
|
|
21
|
+
* WU-1584 Fix #4: Added diagnostic logging to confirm which YAML file is being
|
|
22
|
+
* read for code_paths validation. This helps debug issues where worktree YAML
|
|
23
|
+
* differs from main checkout YAML.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} id - WU ID
|
|
26
|
+
* @param {string|null} worktreePath - Worktree path (null if branch-only mode)
|
|
27
|
+
* @param {string} mainWUPath - Path to WU YAML in main checkout
|
|
28
|
+
* @returns {object} Parsed WU document
|
|
29
|
+
*/
|
|
30
|
+
export declare function readWUPreferWorktree(id: any, worktreePath: any, mainWUPath: any): any;
|
|
31
|
+
/**
|
|
32
|
+
* Detect if currently running inside a worktree
|
|
33
|
+
* Checks for .git file (not directory) which indicates a worktree
|
|
34
|
+
* @returns {string|null} Current directory path if inside worktree, null otherwise
|
|
35
|
+
*/
|
|
36
|
+
export declare function detectCurrentWorktree(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Resolve worktree path from WU YAML
|
|
39
|
+
* Originally implemented in WU-1226, extracted to validators module in WU-1215
|
|
40
|
+
* Priority:
|
|
41
|
+
* 1. Read worktree_path field (set at claim time, immune to lane field changes)
|
|
42
|
+
* 2. Fall back to calculating from lane field (for old WUs without worktree_path)
|
|
43
|
+
* 3. Use git worktree list to find actual path (defensive fallback)
|
|
44
|
+
* @param {object} doc - WU YAML document
|
|
45
|
+
* @returns {Promise<string|null>} - Worktree path or null if not found
|
|
46
|
+
*/
|
|
47
|
+
export declare function defaultWorktreeFrom(doc: any): Promise<any>;
|
|
48
|
+
/**
|
|
49
|
+
* Detect workspace mode from WU YAML
|
|
50
|
+
* @param {object} doc - WU YAML document
|
|
51
|
+
* @returns {'worktree' | 'branch-only'}
|
|
52
|
+
*/
|
|
53
|
+
export declare function detectWorkspaceMode(doc: any): string;
|
|
54
|
+
/**
|
|
55
|
+
* Calculate lane branch name from WU YAML
|
|
56
|
+
* @param {object} doc - WU YAML document
|
|
57
|
+
* @returns {string|null} Lane branch name (e.g., lane/operations-tooling/wu-1215)
|
|
58
|
+
*/
|
|
59
|
+
export declare function defaultBranchFrom(doc: any): string;
|
|
60
|
+
/**
|
|
61
|
+
* Check if a branch exists
|
|
62
|
+
* @param {string} branch - Branch name to check
|
|
63
|
+
* @returns {Promise<boolean>} True if branch exists
|
|
64
|
+
*/
|
|
65
|
+
export declare function branchExists(branch: any): Promise<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Detect workspace mode and calculate all relevant paths
|
|
68
|
+
* @param {string} id - WU ID
|
|
69
|
+
* @param {object} args - Parsed command-line arguments
|
|
70
|
+
* @returns {Promise<object>} Object containing paths, mode info, and WU document
|
|
71
|
+
*/
|
|
72
|
+
export declare function detectModeAndPaths(id: any, args: any): Promise<{
|
|
73
|
+
WU_PATH: string;
|
|
74
|
+
STATUS_PATH: string;
|
|
75
|
+
BACKLOG_PATH: string;
|
|
76
|
+
STAMPS_DIR: string;
|
|
77
|
+
docMain: any;
|
|
78
|
+
workspaceMode: string;
|
|
79
|
+
isBranchOnly: boolean;
|
|
80
|
+
derivedWorktree: any;
|
|
81
|
+
docForValidation: any;
|
|
82
|
+
isDocsOnly: boolean;
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* Generate commit message for WU completion
|
|
86
|
+
* Extracted from wu-done.mjs (WU-1215 Phase 2 Extraction #1 Helper)
|
|
87
|
+
* @param {string} id - WU ID (e.g., "WU-1215")
|
|
88
|
+
* @param {string} title - WU title
|
|
89
|
+
* @param {number} maxLength - Maximum commit header length from commitlint config
|
|
90
|
+
* @returns {string} Formatted commit message
|
|
91
|
+
* @throws {Error} If generated message exceeds maxLength
|
|
92
|
+
*/
|
|
93
|
+
export declare function generateCommitMessage(id: any, title: any, maxLength?: number): string;
|
|
94
|
+
/**
|
|
95
|
+
* Validate that required metadata files exist before updating
|
|
96
|
+
* WU-1275: Fail fast before mutations to prevent partial state
|
|
97
|
+
*
|
|
98
|
+
* @param {object} params - Parameters object
|
|
99
|
+
* @param {string} params.statusPath - Path to status.md file
|
|
100
|
+
* @param {string} params.backlogPath - Path to backlog.md file
|
|
101
|
+
* @throws {WUError} If any required file is missing
|
|
102
|
+
*/
|
|
103
|
+
export declare function validateMetadataFilesExist({ statusPath, backlogPath }: {
|
|
104
|
+
statusPath: any;
|
|
105
|
+
backlogPath: any;
|
|
106
|
+
}): void;
|
|
107
|
+
/**
|
|
108
|
+
* Update all metadata files for WU completion
|
|
109
|
+
* Extracted from wu-done.mjs (WU-1215 Phase 2 Extraction #1 Helper)
|
|
110
|
+
* WU-1572: Made async for WUStateStore integration
|
|
111
|
+
* @param {object} params - Parameters object
|
|
112
|
+
* @param {string} params.id - WU ID
|
|
113
|
+
* @param {string} params.title - WU title
|
|
114
|
+
* @param {object} params.doc - WU YAML document to update
|
|
115
|
+
* @param {string} params.wuPath - Path to WU YAML file
|
|
116
|
+
* @param {string} params.statusPath - Path to status.md file
|
|
117
|
+
* @param {string} params.backlogPath - Path to backlog.md file
|
|
118
|
+
*/
|
|
119
|
+
export declare function updateMetadataFiles({ id, title, doc, wuPath, statusPath, backlogPath }: {
|
|
120
|
+
id: any;
|
|
121
|
+
title: any;
|
|
122
|
+
doc: any;
|
|
123
|
+
wuPath: any;
|
|
124
|
+
statusPath: any;
|
|
125
|
+
backlogPath: any;
|
|
126
|
+
}): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Collect metadata updates to a transaction (WU-1369: Atomic pattern)
|
|
129
|
+
*
|
|
130
|
+
* This is the atomic version of updateMetadataFiles.
|
|
131
|
+
* Instead of writing files immediately, it collects all changes
|
|
132
|
+
* into a WUTransaction object for atomic commit.
|
|
133
|
+
*
|
|
134
|
+
* Usage:
|
|
135
|
+
* ```js
|
|
136
|
+
* const tx = new WUTransaction(id);
|
|
137
|
+
* collectMetadataToTransaction({ id, title, doc, wuPath, statusPath, backlogPath, stampPath, transaction: tx });
|
|
138
|
+
* // All changes are now in tx.pendingWrites
|
|
139
|
+
* // Validate, then commit or abort
|
|
140
|
+
* tx.commit();
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @param {object} params - Parameters object
|
|
144
|
+
* @param {string} params.id - WU ID
|
|
145
|
+
* @param {string} params.title - WU title
|
|
146
|
+
* @param {object} params.doc - WU YAML document to update (will be mutated)
|
|
147
|
+
* @param {string} params.wuPath - Path to WU YAML file
|
|
148
|
+
* @param {string} params.statusPath - Path to status.md file
|
|
149
|
+
* @param {string} params.backlogPath - Path to backlog.md file
|
|
150
|
+
* @param {string} params.stampPath - Path to stamp file
|
|
151
|
+
* @param {WUTransaction} params.transaction - Transaction to add writes to
|
|
152
|
+
*/
|
|
153
|
+
export declare function collectMetadataToTransaction({ id, title, doc, wuPath, statusPath, backlogPath, stampPath, transaction, }: {
|
|
154
|
+
id: any;
|
|
155
|
+
title: any;
|
|
156
|
+
doc: any;
|
|
157
|
+
wuPath: any;
|
|
158
|
+
statusPath: any;
|
|
159
|
+
backlogPath: any;
|
|
160
|
+
stampPath: any;
|
|
161
|
+
transaction: any;
|
|
162
|
+
}): Promise<void>;
|
|
163
|
+
/**
|
|
164
|
+
* Stage and format metadata files
|
|
165
|
+
* Extracted from wu-done.mjs (WU-1215 Phase 2 Extraction #1 Helper)
|
|
166
|
+
* @param {object} params - Parameters object
|
|
167
|
+
* @param {string} params.id - WU ID (for error reporting)
|
|
168
|
+
* @param {string} params.wuPath - Path to WU YAML file
|
|
169
|
+
* @param {string} params.statusPath - Path to status.md file
|
|
170
|
+
* @param {string} params.backlogPath - Path to backlog.md file
|
|
171
|
+
* @param {string} params.stampsDir - Path to stamps directory
|
|
172
|
+
* @throws {Error} If formatting fails
|
|
173
|
+
*/
|
|
174
|
+
export declare function stageAndFormatMetadata({ id, wuPath, statusPath, backlogPath, stampsDir }: {
|
|
175
|
+
id: any;
|
|
176
|
+
wuPath: any;
|
|
177
|
+
statusPath: any;
|
|
178
|
+
backlogPath: any;
|
|
179
|
+
stampsDir: any;
|
|
180
|
+
}): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Run cleanup operations after successful merge
|
|
183
|
+
* Removes worktree and optionally deletes lane branch
|
|
184
|
+
* Extracted from wu-done.mjs (WU-1215 Phase 1 Extraction #3)
|
|
185
|
+
*
|
|
186
|
+
* WU-2241: Now wrapped with cleanup lock to prevent concurrent collision
|
|
187
|
+
* when multiple wu:done commands complete simultaneously.
|
|
188
|
+
*
|
|
189
|
+
* @param {object} docMain - WU YAML document
|
|
190
|
+
* @param {object} args - Parsed CLI arguments
|
|
191
|
+
*/
|
|
192
|
+
export declare function runCleanup(docMain: any, args: any): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* WU-1351: Validate code_paths files exist on main branch
|
|
195
|
+
*
|
|
196
|
+
* Prevents false completions by ensuring all code_paths entries
|
|
197
|
+
* actually exist on the target branch (main or lane branch).
|
|
198
|
+
*
|
|
199
|
+
* This guards against:
|
|
200
|
+
* - Stamps being created for WUs where code never merged
|
|
201
|
+
* - Metadata becoming desynchronized from actual code
|
|
202
|
+
*
|
|
203
|
+
* @param {object} doc - WU YAML document
|
|
204
|
+
* @param {string} id - WU ID
|
|
205
|
+
* @param {ValidateCodePathsExistOptions} options - Options
|
|
206
|
+
* @returns {Promise<{ valid: boolean, errors: string[], missing: string[] }>} Validation result
|
|
207
|
+
*/
|
|
208
|
+
export interface ValidateCodePathsExistOptions {
|
|
209
|
+
/** Branch to check files against (default: 'main') */
|
|
210
|
+
targetBranch?: string;
|
|
211
|
+
/** Worktree path for worktree mode */
|
|
212
|
+
worktreePath?: string | null;
|
|
213
|
+
}
|
|
214
|
+
export declare function validateCodePathsExist(doc: any, id: any, options?: ValidateCodePathsExistOptions): Promise<{
|
|
215
|
+
valid: boolean;
|
|
216
|
+
errors: any[];
|
|
217
|
+
missing: any[];
|
|
218
|
+
}>;
|
|
219
|
+
/**
|
|
220
|
+
* Validate WU spec completeness (WU-1162, WU-1280)
|
|
221
|
+
*
|
|
222
|
+
* Ensures WU specifications are complete before allowing wu:done to proceed.
|
|
223
|
+
* Prevents placeholder WUs from being marked as done.
|
|
224
|
+
*
|
|
225
|
+
* WU-1280: Added tests array validation to catch empty tests.manual early
|
|
226
|
+
* (previously only validated in pre-commit hook, causing late failures).
|
|
227
|
+
*
|
|
228
|
+
* @param {object} doc - WU YAML document
|
|
229
|
+
* @param {string} id - WU ID
|
|
230
|
+
* @returns {{ valid: boolean, errors: string[] }} Validation result
|
|
231
|
+
*/
|
|
232
|
+
export declare function validateSpecCompleteness(doc: any, _id: any): {
|
|
233
|
+
valid: boolean;
|
|
234
|
+
errors: any[];
|
|
235
|
+
};
|
|
236
|
+
export { validateAutomatedTestRequirement };
|
|
237
|
+
/**
|
|
238
|
+
* WU-1617: Post-mutation validation for wu:done
|
|
239
|
+
*
|
|
240
|
+
* Validates that metadata files written by tx.commit() are valid:
|
|
241
|
+
* 1. WU YAML has completed_at field with valid ISO datetime
|
|
242
|
+
* 2. WU YAML has locked: true
|
|
243
|
+
* 3. Stamp file exists
|
|
244
|
+
*
|
|
245
|
+
* This catches schema violations that could persist silently after
|
|
246
|
+
* transaction commit.
|
|
247
|
+
*
|
|
248
|
+
* @param {object} params - Validation parameters
|
|
249
|
+
* @param {string} params.id - WU ID
|
|
250
|
+
* @param {string} params.wuPath - Path to WU YAML file
|
|
251
|
+
* @param {string} params.stampPath - Path to stamp file
|
|
252
|
+
* @returns {{ valid: boolean, errors: string[] }} Validation result
|
|
253
|
+
*/
|
|
254
|
+
export declare function validatePostMutation({ id, wuPath, stampPath }: {
|
|
255
|
+
id: any;
|
|
256
|
+
wuPath: any;
|
|
257
|
+
stampPath: any;
|
|
258
|
+
}): {
|
|
259
|
+
valid: boolean;
|
|
260
|
+
errors: any[];
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* WU-1781: Build preflight error message with actionable guidance
|
|
264
|
+
*
|
|
265
|
+
* Creates a formatted error message for preflight validation failures,
|
|
266
|
+
* including specific guidance for stamp-status mismatch errors.
|
|
267
|
+
*
|
|
268
|
+
* @param {string} id - WU ID being completed
|
|
269
|
+
* @param {string[]} errors - List of validation errors
|
|
270
|
+
* @returns {string} Formatted error message with fix options
|
|
271
|
+
*/
|
|
272
|
+
export declare function buildPreflightErrorMessage(id: any, errors: any): string;
|
|
273
|
+
/**
|
|
274
|
+
* WU-1805: Execute preflight code_paths and test_paths validation
|
|
275
|
+
*
|
|
276
|
+
* Validates that all code_paths and test file paths specified in the WU YAML
|
|
277
|
+
* actually exist before running gates. This catches YAML mismatches early,
|
|
278
|
+
* saving time compared to discovering issues after a full gate run.
|
|
279
|
+
*
|
|
280
|
+
* This is run as the FIRST validation step in wu:done, before gates.
|
|
281
|
+
*
|
|
282
|
+
* @param {string} id - WU ID being completed
|
|
283
|
+
* @param {object} paths - Path options
|
|
284
|
+
* @param {string} paths.rootDir - Root directory for YAML lookup
|
|
285
|
+
* @param {string} paths.worktreePath - Worktree path for file existence checks
|
|
286
|
+
* @param {ExecutePreflightCodePathValidationOptions} options - Options for testing
|
|
287
|
+
* @returns {Promise<{ valid: boolean, errors: string[], missingCodePaths: string[], missingTestPaths: string[], abortedBeforeGates: boolean }>}
|
|
288
|
+
*/
|
|
289
|
+
interface ExecutePreflightCodePathValidationOptions {
|
|
290
|
+
/** Override validatePreflight for testing */
|
|
291
|
+
validatePreflightFn?: typeof validatePreflight;
|
|
292
|
+
}
|
|
293
|
+
export declare function executePreflightCodePathValidation(id: any, paths: any, options?: ExecutePreflightCodePathValidationOptions): Promise<{
|
|
294
|
+
valid: boolean;
|
|
295
|
+
errors: any[];
|
|
296
|
+
missingCodePaths: any[];
|
|
297
|
+
missingTestPaths: any[];
|
|
298
|
+
abortedBeforeGates: boolean;
|
|
299
|
+
}>;
|
|
300
|
+
/**
|
|
301
|
+
* WU-1805: Build preflight code_paths error message with actionable guidance
|
|
302
|
+
*
|
|
303
|
+
* Creates a formatted error message for preflight code_paths validation failures,
|
|
304
|
+
* including specific guidance for fixing missing files.
|
|
305
|
+
*
|
|
306
|
+
* @param {string} id - WU ID being completed
|
|
307
|
+
* @param {object} result - Preflight validation result
|
|
308
|
+
* @param {string[]} result.errors - List of validation errors
|
|
309
|
+
* @param {string[]} result.missingCodePaths - Missing code_paths files
|
|
310
|
+
* @param {string[]} result.missingTestPaths - Missing test files
|
|
311
|
+
* @returns {string} Formatted error message with fix options
|
|
312
|
+
*/
|
|
313
|
+
export declare function buildPreflightCodePathErrorMessage(id: any, result: any): string;
|
|
314
|
+
/**
|
|
315
|
+
* WU-1781: Run tasks:validate as preflight check before any git operations
|
|
316
|
+
*
|
|
317
|
+
* This prevents deadlocks where wu:done completes merge but then pre-push
|
|
318
|
+
* fails on tasks:validate, leaving local main ahead of origin.
|
|
319
|
+
*
|
|
320
|
+
* @param {string} id - WU ID being completed
|
|
321
|
+
* @param {ExecSyncOverrideOptions} options - Options for testing
|
|
322
|
+
* @returns {{ valid: boolean, errors: string[], abortedBeforeMerge: boolean, localMainModified: boolean, hasStampStatusError: boolean }}
|
|
323
|
+
*/
|
|
324
|
+
interface ExecSyncOverrideOptions {
|
|
325
|
+
/** Override execSync for testing (default: child_process.execSync) */
|
|
326
|
+
execSyncFn?: typeof execSyncImport;
|
|
327
|
+
}
|
|
328
|
+
export declare function runPreflightTasksValidation(id: any, options?: ExecSyncOverrideOptions): {
|
|
329
|
+
valid: boolean;
|
|
330
|
+
errors: any;
|
|
331
|
+
abortedBeforeMerge: boolean;
|
|
332
|
+
localMainModified: boolean;
|
|
333
|
+
hasStampStatusError: any;
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* WU-2308: Validate all pre-commit hooks with worktree context
|
|
337
|
+
*
|
|
338
|
+
* Runs pre-commit validation gates from the worktree directory when provided.
|
|
339
|
+
* This ensures that dependency audits check the worktree's dependencies
|
|
340
|
+
* (with any fixes) rather than main's potentially stale dependencies.
|
|
341
|
+
*
|
|
342
|
+
* @param {string} id - WU ID being completed
|
|
343
|
+
* @param {string|null} worktreePath - Path to worktree (null = run from current dir)
|
|
344
|
+
* @param {ExecSyncOverrideOptions} options - Options for testing
|
|
345
|
+
* @returns {{ valid: boolean, errors: string[] }}
|
|
346
|
+
*/
|
|
347
|
+
export declare function validateAllPreCommitHooks(id: any, worktreePath?: any, options?: ExecSyncOverrideOptions): {
|
|
348
|
+
valid: boolean;
|
|
349
|
+
errors: any[];
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* WU-2242: Validate that test_paths is required for non-doc WUs
|
|
353
|
+
*
|
|
354
|
+
* Enforces that WUs with code changes (non-documentation types with code_paths
|
|
355
|
+
* that contain actual code) have at least one test path specified.
|
|
356
|
+
*
|
|
357
|
+
* Returns valid: true in the following cases:
|
|
358
|
+
* - WU type is 'documentation' or 'process'
|
|
359
|
+
* - code_paths is empty or only contains documentation paths
|
|
360
|
+
* - tests object has at least one test (unit, e2e, manual, or integration)
|
|
361
|
+
*
|
|
362
|
+
* @param {object} wu - WU document
|
|
363
|
+
* @param {string} wu.id - WU ID
|
|
364
|
+
* @param {string} wu.type - WU type (feature, bug, documentation, etc.)
|
|
365
|
+
* @param {object} wu.tests - Tests object with unit, e2e, manual, integration arrays
|
|
366
|
+
* @param {string[]} wu.code_paths - Array of code paths
|
|
367
|
+
* @returns {{ valid: boolean, error?: string }}
|
|
368
|
+
*/
|
|
369
|
+
export declare function validateTestPathsRequired(wu: any): {
|
|
370
|
+
valid: boolean;
|
|
371
|
+
error?: undefined;
|
|
372
|
+
} | {
|
|
373
|
+
valid: boolean;
|
|
374
|
+
error: string;
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
* WU-2310: Validate type vs code_paths at preflight (before transaction starts).
|
|
378
|
+
*
|
|
379
|
+
* This catches the documentation WU + code file mismatch BEFORE any transaction
|
|
380
|
+
* begins, preventing the scenario where:
|
|
381
|
+
* 1. Transaction commits files (stamp, status, backlog)
|
|
382
|
+
* 2. Git commit fails due to pre-commit hook (gateDocsOnlyPathEnforcement)
|
|
383
|
+
* 3. Files are left in inconsistent state
|
|
384
|
+
*
|
|
385
|
+
* By running this validation at preflight, we fail fast with a clear error
|
|
386
|
+
* message before any file mutations occur.
|
|
387
|
+
*
|
|
388
|
+
* @param {object} wu - WU document
|
|
389
|
+
* @param {string} wu.id - WU ID
|
|
390
|
+
* @param {string} wu.type - WU type (documentation, feature, bug, etc.)
|
|
391
|
+
* @param {string[]} [wu.code_paths] - Array of code paths
|
|
392
|
+
* @returns {{ valid: boolean, errors: string[], blockedPaths: string[], abortedBeforeTransaction: boolean }}
|
|
393
|
+
*/
|
|
394
|
+
export declare function validateTypeVsCodePathsPreflight(wu: any): {
|
|
395
|
+
valid: boolean;
|
|
396
|
+
errors: any[];
|
|
397
|
+
blockedPaths: any[];
|
|
398
|
+
abortedBeforeTransaction: boolean;
|
|
399
|
+
};
|
|
400
|
+
/**
|
|
401
|
+
* WU-2310: Build error message for type vs code_paths preflight failure.
|
|
402
|
+
*
|
|
403
|
+
* Provides actionable guidance for fixing the mismatch:
|
|
404
|
+
* 1. Change WU type to 'engineering' or appropriate type
|
|
405
|
+
* 2. Update code_paths to only include documentation files
|
|
406
|
+
*
|
|
407
|
+
* @param {string} id - WU ID
|
|
408
|
+
* @param {string[]} blockedPaths - Paths that would be blocked
|
|
409
|
+
* @returns {string} Formatted error message
|
|
410
|
+
*/
|
|
411
|
+
export declare function buildTypeVsCodePathsErrorMessage(id: any, blockedPaths: any): string;
|