## Summary
Wave 18 continues the package code-organization program after wave 17
domain folders (U4 Slice A from
`docs/plans/2026-07-14-001-refactor-package-code-organization-plan.md`).
### What changed
Peel **pure, behavior-preserving** helpers out of
`packages/engine/src/executor.ts` into domain modules under
`packages/engine/src/executor/`, with **stable re-exports** from
`executor.ts` so deep imports and `vi.mock("../executor.js")` keep
working.
| New module | Symbols |
|------------|---------|
| `executor/task-done-refusal.ts` | `evaluateTaskDoneRefusal`,
`determineRevisionResetStart`, skip-bypass refusal helper |
| `executor/workflow-feedback-paths.ts` |
`extractReferencedPathsFromWorkflowFeedback`,
`isAlwaysAllowedScopeLeakPath`, `workflowPathMatchesDeclaredScope` |
| `executor/workflow-step-verdict.ts` |
`FUSION_WORKFLOW_STEP_CONVENTIONS_PREAMBLE`, `parseWorkflowStepVerdict`
/ `parseWorkflowStepOutput`, step outcome types |
| `executor/await-input-parse.ts` | `parseAwaitInputSentinel`,
`parseAwaitInputQuestionToolCall` |
| `executor/no-commit-eligibility.ts` | `getNoCommitEligibilityReason`
(+ prompt heuristics) |
`executor.ts` live LOC ~**22817 → ~22427** (first pure-peel batch; more
peels needed to approach the 2k cap).
### Shims
- `old path` `executor.ts` public exports → `new path` `executor/*.ts` →
delete-when consumer deep-imports are re-pointed (not this PR)
### Test plan
- [x] `@fusion/engine` typecheck
- [x] Oracle: task-done refusal, skip-bypass, workflow malformed
verdict, scope-leak allowlist, executor-step-session, executor-prompt
- [x] `vitest --project=engine-core` (merge-gate curated suite)
- [ ] CI merge gate
**Stack:** wave17 (merged) → **this PR**
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Improved recognition of workflow outcomes from structured and
conversational responses.
* Added support for extracting questions from await-input responses and
tool calls.
* Improved workflow feedback handling for referenced files and declared
scope patterns.
* Added clearer guidance for task execution, approvals, verification,
and available tools.
* **Bug Fixes**
* Prevented completion when required review approvals are missing or
revisions remain pending.
* Improved handling of workflows that legitimately require no code
changes.
* Added clearer refusal messages and more reliable revision restarts.
* Sanitized repository paths in Git remediation instructions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
75 lines
3.2 KiB
TypeScript
75 lines
3.2 KiB
TypeScript
/**
|
|
* FNXC:CodeOrganization 2026-08-03-07:20:
|
|
* Pure workflow-feedback path helpers peeled from executor.ts (wave18 / U4 Slice A).
|
|
*/
|
|
import { normalizeRepoRelPath } from "../worktree/workspace-paths.js";
|
|
|
|
export interface WorkflowRevisionFeedbackPartition {
|
|
inScopeFeedback: string;
|
|
outOfScopeFeedback: string;
|
|
inScopeSegments: string[];
|
|
outOfScopeSegments: string[];
|
|
detectedPaths: string[];
|
|
}
|
|
|
|
const WORKFLOW_FEEDBACK_PATH_REGEX = /`([^`\n]+)`|(?<![A-Za-z0-9_.-])((?:\.\.?\/)?(?:@?[A-Za-z0-9._-]+\/)+[A-Za-z0-9._-]+(?:\.[A-Za-z0-9._-]+)?)/g;
|
|
|
|
// FNXC:Workspace 2026-06-21-15:00: F8 — delegate to the single shared normalizer (workspace-paths.ts).
|
|
// Was a near-duplicate that did NOT strip a leading slash and only collapsed a single trailing slash;
|
|
// the shared `normalizeRepoRelPath` additionally strips leading slashes and collapses repeated trailing
|
|
// slashes. For repo-relative inputs (the only inputs in practice) the result is unchanged; the extra
|
|
// canonicalization only hardens absolute/trailing-slash edge cases so workspace and non-workspace scope
|
|
// matching agree. Kept as a thin alias so existing call sites stay put.
|
|
function normalizeWorkflowScopePath(pathValue: string): string {
|
|
return normalizeRepoRelPath(pathValue);
|
|
}
|
|
|
|
function stripTrailingPathPunctuation(pathValue: string): string {
|
|
return pathValue.replace(/[),.:;!?]+$/g, "");
|
|
}
|
|
|
|
export function extractReferencedPathsFromWorkflowFeedback(feedback: string): string[] {
|
|
const extracted: string[] = [];
|
|
const seen = new Set<string>();
|
|
for (const match of feedback.matchAll(WORKFLOW_FEEDBACK_PATH_REGEX)) {
|
|
const candidate = stripTrailingPathPunctuation(match[1] ?? match[2] ?? "");
|
|
const normalized = normalizeWorkflowScopePath(candidate);
|
|
if (!normalized.includes("/")) continue;
|
|
if (seen.has(normalized)) continue;
|
|
seen.add(normalized);
|
|
extracted.push(normalized);
|
|
}
|
|
return extracted;
|
|
}
|
|
|
|
/**
|
|
* FN-4811 follow-up: paths the scope-leak guard never flags, regardless of declared
|
|
* scope. These are file types every task may legitimately touch as part of standard
|
|
* delivery (e.g., `.changeset/` per AGENTS.md's "Finalizing Changes" section).
|
|
* Cross-task contamination of these paths is caught by stronger guards downstream
|
|
* (file-scope invariant at squash commit, branch-tip checks, post-merge audit).
|
|
*/
|
|
export function isAlwaysAllowedScopeLeakPath(filePath: string): boolean {
|
|
const normalizedPath = normalizeWorkflowScopePath(filePath);
|
|
return normalizedPath.startsWith(".changeset/");
|
|
}
|
|
|
|
export function workflowPathMatchesDeclaredScope(filePath: string, scopePatterns: readonly string[]): boolean {
|
|
const normalizedPath = normalizeWorkflowScopePath(filePath);
|
|
for (const rawPattern of scopePatterns) {
|
|
const pattern = normalizeWorkflowScopePath(rawPattern);
|
|
if (!pattern) continue;
|
|
if (/\/\*+$/.test(pattern)) {
|
|
const directory = pattern.replace(/\/\*+$/, "");
|
|
if (normalizedPath === directory || normalizedPath.startsWith(`${directory}/`)) return true;
|
|
continue;
|
|
}
|
|
if (pattern.endsWith("/")) {
|
|
if (normalizedPath.startsWith(pattern)) return true;
|
|
continue;
|
|
}
|
|
if (normalizedPath === pattern) return true;
|
|
}
|
|
return false;
|
|
}
|