@leitwerk-dev/coding 0.5.6 → 0.5.7

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.
Files changed (31) hide show
  1. package/README.md +13 -0
  2. package/dist/{chunk-B3PE6DPF.js → chunk-JL53OV5M.js} +74 -67
  3. package/dist/chunk-JL53OV5M.js.map +1 -0
  4. package/dist/{chunk-QD6FI4HR.js → chunk-PISZZXK4.js} +3 -4
  5. package/dist/chunk-PISZZXK4.js.map +1 -0
  6. package/dist/{chunk-3WJRJ3Q7.js → chunk-VG6XF3OK.js} +2 -6
  7. package/dist/chunk-VG6XF3OK.js.map +1 -0
  8. package/dist/finalization-git-internal.d.ts.map +1 -1
  9. package/dist/finalization-git.js +1 -1
  10. package/dist/index.js +2 -2
  11. package/dist/{repository-change-launch-internal-BudnAfL7.d.ts → repository-change-launch-internal-CP2jJJCR.d.ts} +1 -1
  12. package/dist/{repository-change-process-DlgF04fU.d.ts → repository-change-process-DbcnkzLw.d.ts} +2 -0
  13. package/dist/repository-change-process.d.ts +2 -0
  14. package/dist/repository-change-process.d.ts.map +1 -1
  15. package/dist/repository-change-publication.d.ts.map +1 -1
  16. package/dist/repository-change-publication.js +14 -26
  17. package/dist/repository-change-publication.js.map +1 -1
  18. package/dist/repository-reconciliation.d.ts +9 -15
  19. package/dist/repository-reconciliation.d.ts.map +1 -1
  20. package/dist/turns/implement.d.ts +1 -1
  21. package/dist/turns/implement.d.ts.map +1 -1
  22. package/dist/turns/implement.js +1 -1
  23. package/package.json +5 -5
  24. package/src/finalization-git-internal.ts +1 -5
  25. package/src/repository-change-process.ts +5 -1
  26. package/src/repository-change-publication.ts +13 -27
  27. package/src/repository-reconciliation.ts +97 -84
  28. package/src/turns/implement.ts +2 -2
  29. package/dist/chunk-3WJRJ3Q7.js.map +0 -1
  30. package/dist/chunk-B3PE6DPF.js.map +0 -1
  31. package/dist/chunk-QD6FI4HR.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/actions.ts","../src/repository-reconciliation.ts","../src/repository-change-process.ts","../src/repository-change-state-internal.ts"],"sourcesContent":["import type { FormDefinition } from \"@leitwerk-dev/process-sdk\";\n\n/** @public */\nexport const codingActionIds = {\n\t/** @public */\n\tapprovePlan: \"approve_plan\",\n\t/** @internal */\n\trequestRevision: \"request_revision\",\n\t/** @internal */\n\trunReview: \"run_review\",\n\t/** @internal */\n\tsimplify: \"simplify\",\n\t/** @internal */\n\tacceptReview: \"accept_review\",\n\t/** @internal */\n\trequestReviewChanges: \"request_review_changes\",\n\t/** @internal */\n\tdismissReview: \"dismiss_review\",\n\t/** @public */\n\tfinalizeChange: \"finalize_change\",\n} as const;\n\nfunction notesForm(id: string, title: string, label: string, description: string): FormDefinition {\n\treturn {\n\t\tid,\n\t\ttitle,\n\t\tfields: [\n\t\t\t{ id: \"message\", label, kind: \"textarea\", primaryPrompt: true, required: true, description },\n\t\t],\n\t\tsubmitLabel: title,\n\t};\n}\n\n/** @internal */\nexport const requestRevisionForm = notesForm(\n\tcodingActionIds.requestRevision,\n\t\"Request revision\",\n\t\"Revision notes\",\n\t\"Instructions for the next implementation pass.\",\n);\n/** @internal */\nexport const requestReviewChangesForm = notesForm(\n\tcodingActionIds.requestReviewChanges,\n\t\"Request review changes\",\n\t\"Review notes\",\n\t\"Instructions for the next review pass.\",\n);\n/** @internal */\nexport const acceptReviewForm: FormDefinition = {\n\tid: codingActionIds.acceptReview,\n\ttitle: \"Accept review\",\n\tfields: [\n\t\t{\n\t\t\tid: \"message\",\n\t\t\tlabel: \"Review adjustment\",\n\t\t\tkind: \"textarea\",\n\t\t\tprimaryPrompt: true,\n\t\t\tdescription:\n\t\t\t\t\"Optional instructions to apply with the accepted review, such as dropping one finding.\",\n\t\t},\n\t],\n\tsubmitLabel: \"Accept review\",\n};\n","import { execFileSync } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { hostname } from \"node:os\";\nimport { join } from \"node:path\";\nimport { repositoryGitArgs, repositoryGitSubprocessEnv } from \"@leitwerk-dev/process-sdk\";\nimport { resolveGitBinary } from \"@leitwerk-dev/process-sdk/git-binary\";\nimport type { GitIdentity } from \"./finalization-git.js\";\nimport {\n\ttype RepositoryBinding,\n\treadPublicationReceipt,\n\treadRepositoryBinding,\n\trepositoryBindingMatches,\n\tsavePublicationReceipt,\n} from \"./repository-publication-receipt.js\";\nimport { repositoryRecord } from \"./repository-record.js\";\n\n/** @internal */\nexport interface ReconciliationInput {\n\tprojectKey: string;\n\trepoPath: string;\n\tworkBranch: string;\n\t/** Last remote baseline, not the latest observation. */\n\tbaselineSha: string;\n\t/** Trusted project identity for replaying unpublished commits. */\n\tgitIdentity?: GitIdentity;\n}\n\n/** @internal */\nexport interface ReconciliationResult {\n\tstatus: \"ready\" | \"conflicts\";\n\tremoteHead: string | null;\n\theadSha: string;\n\tchanged: boolean;\n}\n\ninterface RecordState extends RepositoryBinding {\n\tbaseline: string;\n\tremoteSeen?: boolean;\n\tprotectedIgnored?: string[];\n\tpublicationReceiptSha?: string;\n\tjoinParent?: string;\n\tjoinIdentity?: GitIdentity;\n\tsourceIntegration?: { previous: string; replacement: string };\n\toperation?: {\n\t\tid: string;\n\t\thead: string;\n\t\tindex: string;\n\t\twork: string;\n\t\tremote: string;\n\t\tphase: \"captured\" | \"rebasing\" | \"restoring\";\n\t\tresultHead?: string;\n\t\tresultIndex?: string;\n\t\tidentity?: GitIdentity;\n\t};\n}\n\nfunction repository(input: Pick<ReconciliationInput, \"projectKey\" | \"repoPath\">) {\n\tfunction git(args: string[], extra: NodeJS.ProcessEnv = {}): string {\n\t\tconst output = execFileSync(resolveGitBinary(), repositoryGitArgs(args), {\n\t\t\tcwd: input.repoPath,\n\t\t\tencoding: \"utf8\",\n\t\t\tenv: repositoryGitSubprocessEnv(input.projectKey, {\n\t\t\t\tGIT_TERMINAL_PROMPT: \"0\",\n\t\t\t\tGIT_EDITOR: \"true\",\n\t\t\t\tGIT_SEQUENCE_EDITOR: \"true\",\n\t\t\t\t...extra,\n\t\t\t}),\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\tmaxBuffer: 16 * 1024 * 1024,\n\t\t});\n\t\treturn output.endsWith(\"\\0\") ? output : output.replace(/\\r?\\n$/, \"\");\n\t}\n\tconst directory = git([\"rev-parse\", \"--absolute-git-dir\"]);\n\tif (\n\t\tgit([\"remote\", \"get-url\", \"--push\", \"--all\", \"origin\"]) !== git([\"remote\", \"get-url\", \"origin\"])\n\t)\n\t\tthrow new Error(\n\t\t\t\"Repository reconciliation binding changed: fetch and push endpoints must match\",\n\t\t);\n\tconst { read, save } = repositoryRecord<RecordState>(directory, \"reconciliation\");\n\tconst binding = (branch: string) => readRepositoryBinding((...args) => git(args), branch);\n\treturn { git, directory, read, save, binding };\n}\n\nfunction integrationIdentityEnv(identity: GitIdentity | undefined): NodeJS.ProcessEnv {\n\tif (\n\t\t!identity?.name.trim() ||\n\t\t!identity.email.trim() ||\n\t\t/[\\r\\n\\0]/.test(identity.name + identity.email)\n\t)\n\t\tthrow new Error(\n\t\t\t\"A trusted Git identity is required for source integration; local work was retained\",\n\t\t);\n\treturn {\n\t\tGIT_AUTHOR_NAME: identity.name,\n\t\tGIT_AUTHOR_EMAIL: identity.email,\n\t\tGIT_COMMITTER_NAME: identity.name,\n\t\tGIT_COMMITTER_EMAIL: identity.email,\n\t};\n}\n\nfunction ignoredPaths(git: ReturnType<typeof repository>[\"git\"]): string[] {\n\treturn git([\n\t\t\"ls-files\",\n\t\t\"--others\",\n\t\t\"--ignored\",\n\t\t\"--exclude-standard\",\n\t\t\"--directory\",\n\t\t\"--no-empty-directory\",\n\t\t\"-z\",\n\t])\n\t\t.split(\"\\0\")\n\t\t.filter(Boolean)\n\t\t.map((file) => file.replace(/\\/$/, \"\"));\n}\n\nfunction assertIgnoredProtection(\n\tgit: ReturnType<typeof repository>[\"git\"],\n\tprotectedPaths: string[] = [],\n): void {\n\tif (!protectedPaths.length) return;\n\tconst visible = git([\"ls-files\", \"--cached\", \"--others\", \"--exclude-standard\", \"-z\"]).split(\"\\0\");\n\tif (\n\t\tprotectedPaths.some((ignored) =>\n\t\t\tvisible.some((file) => file === ignored || file.startsWith(`${ignored}/`)),\n\t\t)\n\t)\n\t\tthrow new Error(\n\t\t\t\"Previously ignored local files became publishable; review ignore rules before continuing. Local files were retained\",\n\t\t);\n}\n\nfunction ignoredPathsCollide(\n\tgit: ReturnType<typeof repository>[\"git\"],\n\tignored: string[],\n\ttarget: string,\n\treplayRange: string,\n): boolean {\n\tconst paths = [\n\t\t...git([\"ls-tree\", \"-r\", \"--name-only\", \"-z\", target]).split(\"\\0\"),\n\t\t...git([\"log\", \"--format=\", \"--full-history\", \"-m\", \"--name-only\", \"-z\", replayRange]).split(\n\t\t\t\"\\0\",\n\t\t),\n\t];\n\treturn ignored.some((file) =>\n\t\tpaths.some((p) => p === file || p.startsWith(`${file}/`) || file.startsWith(`${p}/`)),\n\t);\n}\n\nfunction ancestor(git: ReturnType<typeof repository>[\"git\"], a: string, b: string): boolean {\n\ttry {\n\t\tgit([\"merge-base\", \"--is-ancestor\", a, b]);\n\t\treturn true;\n\t} catch (error) {\n\t\tif ((error as { status?: number }).status === 1) return false;\n\t\tthrow error;\n\t}\n}\n\nfunction withLock<T>(directory: string, run: () => T): T {\n\tconst lock = join(directory, \"leitwerk-reconciliation.lock\");\n\ttry {\n\t\tmkdirSync(lock);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n\t\t// Never steal a lock from another node or a living process.\n\t\tconst owner = JSON.parse(readFileSync(join(lock, \"owner.json\"), \"utf8\"));\n\t\tif (owner.host !== hostname())\n\t\t\tthrow new Error(\"Repository reconciliation is owned by another worker\");\n\t\ttry {\n\t\t\tprocess.kill(owner.pid, 0);\n\t\t} catch (failure) {\n\t\t\tif ((failure as NodeJS.ErrnoException).code !== \"ESRCH\") throw failure;\n\t\t\trmSync(lock, { recursive: true });\n\t\t\treturn withLock(directory, run);\n\t\t}\n\t\tthrow new Error(\"Repository reconciliation is already running\");\n\t}\n\ttry {\n\t\twriteFileSync(\n\t\t\tjoin(lock, \"owner.json\"),\n\t\t\tJSON.stringify({ host: hostname(), pid: process.pid }),\n\t\t\t{ mode: 0o600 },\n\t\t);\n\t\treturn run();\n\t} finally {\n\t\trmSync(lock, { recursive: true });\n\t}\n}\n\n/**\n * Reconcile only unpublished work onto the fetched source branch. Checkpoint commits\n * retain the index and working tree separately, including non-ignored untracked files.\n * They are retained under private refs and removed from HEAD before publication.\n * A conflicted rebase is deliberately left in place for the existing adjustment turn.\n * @internal\n */\nexport function reconcileRepository(input: ReconciliationInput): ReconciliationResult {\n\tconst { git, directory, read, save, binding: readBinding } = repository(input);\n\treturn withLock(directory, () => {\n\t\tgit([\"check-ref-format\", `refs/heads/${input.workBranch}`]);\n\t\tconst binding = readBinding(input.workBranch);\n\t\tlet record = read();\n\t\tif (!repositoryBindingMatches(record, binding))\n\t\t\tthrow new Error(\"Repository reconciliation binding changed\");\n\t\tif (record?.sourceIntegration) {\n\t\t\tif (git([\"branch\", \"--show-current\"]) !== input.workBranch)\n\t\t\t\tthrow new Error(\"Source integration checkout branch changed; local work was retained\");\n\t\t\tconst { previous, replacement } = record.sourceIntegration;\n\t\t\tconst current = git([\"rev-parse\", \"HEAD\"]);\n\t\t\tif (current === previous)\n\t\t\t\tgit([\"update-ref\", `refs/heads/${input.workBranch}`, replacement, previous]);\n\t\t\telse if (current !== replacement)\n\t\t\t\tthrow new Error(\"Checkout changed during source integration; recovery refs were retained\");\n\t\t\tdelete record.sourceIntegration;\n\t\t\tsave(record);\n\t\t}\n\t\tconst rebaseActive = () =>\n\t\t\t[\"rebase-merge\", \"rebase-apply\"].some((name) => existsSync(join(directory, name)));\n\t\tif (rebaseActive() && !record?.operation)\n\t\t\tthrow new Error(\"An unrelated rebase is already in progress; local work was retained\");\n\t\tif (\n\t\t\texistsSync(join(directory, \"MERGE_HEAD\")) ||\n\t\t\texistsSync(join(directory, \"CHERRY_PICK_HEAD\"))\n\t\t)\n\t\t\tthrow new Error(\"An unrelated Git operation is in progress; local work was retained\");\n\t\tif (!rebaseActive() && git([\"branch\", \"--show-current\"]) !== input.workBranch)\n\t\t\tthrow new Error(`Expected checkout on '${input.workBranch}'; local work was retained`);\n\n\t\tif (!record?.operation) {\n\t\t\tassertIgnoredProtection(git, record?.protectedIgnored);\n\t\t\tconst ignored = ignoredPaths(git);\n\t\t\t// Fetch to a private ref: remote-tracking refs are not publication leases.\n\t\t\tgit([\n\t\t\t\t\"fetch\",\n\t\t\t\t\"--no-tags\",\n\t\t\t\t\"origin\",\n\t\t\t\t`+refs/heads/${input.workBranch}:refs/leitwerk/reconcile-remote`,\n\t\t\t]);\n\t\t\tconst remote = git([\"rev-parse\", \"refs/leitwerk/reconcile-remote\"]);\n\t\t\tconst head = git([\"rev-parse\", \"HEAD\"]);\n\t\t\tlet baseline = record?.baseline ?? input.baselineSha;\n\t\t\tconst receipt = readPublicationReceipt(directory);\n\t\t\tif (!repositoryBindingMatches(receipt, binding))\n\t\t\t\tthrow new Error(\"Repository publication receipt binding changed\");\n\t\t\tif (receipt?.status === \"attempting\") {\n\t\t\t\tif (remote === receipt.candidate || ancestor(git, receipt.candidate, remote)) {\n\t\t\t\t\treceipt.status = \"accepted\";\n\t\t\t\t\tsavePublicationReceipt(directory, receipt);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Prior publication outcome is uncertain; local work was retained for operator reconciliation\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (receipt?.status === \"accepted\" && record?.publicationReceiptSha !== receipt.candidate)\n\t\t\t\tbaseline = receipt.candidate;\n\t\t\tgit([\"cat-file\", \"-e\", `${baseline}^{commit}`]);\n\t\t\tif (!ancestor(git, baseline, head))\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Cannot establish unpublished work from the retained baseline; local work was retained\",\n\t\t\t\t);\n\t\t\trecord = {\n\t\t\t\t...record,\n\t\t\t\t...binding,\n\t\t\t\tbaseline,\n\t\t\t\tremoteSeen: true,\n\t\t\t\tprotectedIgnored: [...new Set([...(record?.protectedIgnored ?? []), ...ignored])],\n\t\t\t\tpublicationReceiptSha:\n\t\t\t\t\treceipt?.status === \"accepted\" ? receipt.candidate : record?.publicationReceiptSha,\n\t\t\t};\n\t\t\tif ((remote === baseline || remote === head) && !record.joinParent) {\n\t\t\t\trecord.baseline = remote;\n\t\t\t\tsave(record);\n\t\t\t\treturn { status: \"ready\", remoteHead: remote, headSha: head, changed: false };\n\t\t\t}\n\t\t\tif (git([\"diff\", \"--name-only\", \"--diff-filter=U\"]))\n\t\t\t\tthrow new Error(\"Unresolved local conflicts must be repaired before reconciliation\");\n\t\t\t// Dirty submodule work cannot be represented by the parent's tree checkpoint.\n\t\t\tif (git([\"submodule\", \"foreach\", \"--quiet\", \"git status --porcelain\"]))\n\t\t\t\tthrow new Error(\"Commit or preserve dirty submodule work before reconciliation\");\n\t\t\tif (ignoredPathsCollide(git, ignored, remote, `${record.baseline}..${head}`))\n\t\t\t\tthrow new Error(\"Remote changes collide with ignored files; local files were retained\");\n\t\t\t// A verified remote descendant already contains these local commits, including\n\t\t\t// publication that succeeded before its receipt reached the server.\n\t\t\tif (ancestor(git, head, remote)) record.baseline = head;\n\t\t\tconst id = randomUUID();\n\t\t\tconst temporaryIndex = join(directory, `leitwerk-index-${id}`);\n\t\t\tconst identity = {\n\t\t\t\tGIT_AUTHOR_NAME: \"Leitwerk checkpoint\",\n\t\t\t\tGIT_AUTHOR_EMAIL: \"checkpoint@leitwerk.invalid\",\n\t\t\t\tGIT_COMMITTER_NAME: \"Leitwerk checkpoint\",\n\t\t\t\tGIT_COMMITTER_EMAIL: \"checkpoint@leitwerk.invalid\",\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst stagedTree = git([\"write-tree\"]);\n\t\t\t\tconst index = git(\n\t\t\t\t\t[\"commit-tree\", stagedTree, \"-p\", head, \"-m\", `Leitwerk index checkpoint ${id}`],\n\t\t\t\t\tidentity,\n\t\t\t\t);\n\t\t\t\tgit([\"read-tree\", stagedTree], { GIT_INDEX_FILE: temporaryIndex });\n\t\t\t\tgit([\"add\", \"--all\"], { GIT_INDEX_FILE: temporaryIndex });\n\t\t\t\tconst workTree = git([\"write-tree\"], { GIT_INDEX_FILE: temporaryIndex });\n\t\t\t\tconst work = git(\n\t\t\t\t\t[\"commit-tree\", workTree, \"-p\", index, \"-m\", `Leitwerk worktree checkpoint ${id}`],\n\t\t\t\t\tidentity,\n\t\t\t\t);\n\t\t\t\t// Reachability and journal precede every change to the checkout.\n\t\t\t\tgit([\"update-ref\", `refs/leitwerk/checkpoints/${id}`, work]);\n\t\t\t\tconst replayIdentity = record.joinIdentity ?? input.gitIdentity;\n\t\t\t\tif (replayIdentity || record.baseline !== head) integrationIdentityEnv(replayIdentity);\n\t\t\t\trecord.operation = {\n\t\t\t\t\tid,\n\t\t\t\t\thead,\n\t\t\t\t\tindex,\n\t\t\t\t\twork,\n\t\t\t\t\tremote,\n\t\t\t\t\tphase: \"captured\",\n\t\t\t\t\tidentity: replayIdentity,\n\t\t\t\t};\n\t\t\t\tsave(record);\n\t\t\t} finally {\n\t\t\t\trmSync(temporaryIndex, { force: true });\n\t\t\t}\n\t\t}\n\t\tconst operation = record.operation;\n\t\tif (!operation) throw new Error(\"Missing reconciliation checkpoint\");\n\t\tif (operation.phase === \"captured\") {\n\t\t\tif (operation.identity || record.baseline !== operation.head)\n\t\t\t\tintegrationIdentityEnv(operation.identity);\n\t\t\tconst current = git([\"rev-parse\", \"HEAD\"]);\n\t\t\tconst indexTree = git([\"write-tree\"]);\n\t\t\tif (\n\t\t\t\t![operation.head, operation.work].includes(current) ||\n\t\t\t\t![\n\t\t\t\t\tgit([\"rev-parse\", `${operation.index}^{tree}`]),\n\t\t\t\t\tgit([\"rev-parse\", `${operation.work}^{tree}`]),\n\t\t\t\t].includes(indexTree)\n\t\t\t)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Checkout changed after its checkpoint; new local work and recovery refs were retained\",\n\t\t\t\t);\n\t\t\t// read-tree changes only the index; the worktree already has this exact tree.\n\t\t\tgit([\"read-tree\", operation.work]);\n\t\t\tif (current !== operation.work)\n\t\t\t\tgit([\"update-ref\", `refs/heads/${input.workBranch}`, operation.work, operation.head]);\n\t\t\toperation.phase = \"rebasing\";\n\t\t\tsave(record);\n\t\t}\n\t\tif (operation.phase === \"rebasing\") {\n\t\t\tconst conflicts = (): ReconciliationResult => ({\n\t\t\t\tstatus: \"conflicts\",\n\t\t\t\tremoteHead: operation.remote,\n\t\t\t\theadSha: git([\"rev-parse\", \"HEAD\"]),\n\t\t\t\tchanged: true,\n\t\t\t});\n\t\t\tif (rebaseActive()) return conflicts();\n\t\t\t// Retry after Git completed the rebase but before the result was journaled.\n\t\t\tif (git([\"rev-parse\", \"HEAD\"]) === operation.work) {\n\t\t\t\ttry {\n\t\t\t\t\tgit(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"-c\",\n\t\t\t\t\t\t\t\"core.hooksPath=/dev/null\",\n\t\t\t\t\t\t\t\"-c\",\n\t\t\t\t\t\t\t\"commit.gpgSign=false\",\n\t\t\t\t\t\t\t\"rebase\",\n\t\t\t\t\t\t\t\"--rebase-merges\",\n\t\t\t\t\t\t\t\"--reapply-cherry-picks\",\n\t\t\t\t\t\t\t\"--empty=keep\",\n\t\t\t\t\t\t\t\"--onto\",\n\t\t\t\t\t\t\toperation.remote,\n\t\t\t\t\t\t\trecord.baseline,\n\t\t\t\t\t\t],\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tGIT_COMMITTER_NAME: operation.identity?.name ?? \"Leitwerk checkpoint\",\n\t\t\t\t\t\t\tGIT_COMMITTER_EMAIL: operation.identity?.email ?? \"checkpoint@leitwerk.invalid\",\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!rebaseActive()) throw error;\n\t\t\t\t\treturn conflicts();\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tgit([\"log\", \"-1\", \"--format=%s\"]) !== `Leitwerk worktree checkpoint ${operation.id}` ||\n\t\t\t\tgit([\"log\", \"-1\", \"--format=%s\", \"HEAD^\"]) !== `Leitwerk index checkpoint ${operation.id}`\n\t\t\t)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Reconciliation checkpoint commits were changed or skipped; recovery refs were retained\",\n\t\t\t\t);\n\t\t\toperation.resultHead = git([\"rev-parse\", \"HEAD~2\"]);\n\t\t\toperation.resultIndex = git([\"rev-parse\", \"HEAD~1^{tree}\"]);\n\t\t\t// Preserve the integrated working tree/index before removing checkpoint commits.\n\t\t\tgit([\"update-ref\", `refs/leitwerk/reconciled/${operation.id}`, git([\"rev-parse\", \"HEAD\"])]);\n\t\t\toperation.phase = \"restoring\";\n\t\t\tsave(record);\n\t\t}\n\t\tif (!operation.resultHead || !operation.resultIndex)\n\t\t\tthrow new Error(\"Incomplete reconciliation result\");\n\t\tif (record.joinParent && !ancestor(git, record.joinParent, operation.resultHead)) {\n\t\t\t// The net repair was replayed against the current source. Retain the target\n\t\t\t// ancestry without re-merging (and thereby losing the replayed resolution).\n\t\t\toperation.resultHead = git(\n\t\t\t\t[\n\t\t\t\t\t\"commit-tree\",\n\t\t\t\t\tgit([\"rev-parse\", `${operation.resultHead}^{tree}`]),\n\t\t\t\t\t\"-p\",\n\t\t\t\t\toperation.resultHead,\n\t\t\t\t\t\"-p\",\n\t\t\t\t\trecord.joinParent,\n\t\t\t\t\t\"-m\",\n\t\t\t\t\t\"Integrate target branch with concurrent source changes\",\n\t\t\t\t],\n\t\t\t\tintegrationIdentityEnv(record.joinIdentity),\n\t\t\t);\n\t\t\tgit([\n\t\t\t\t\"update-ref\",\n\t\t\t\t`refs/leitwerk/target-integrations/${operation.id}`,\n\t\t\t\toperation.resultHead,\n\t\t\t]);\n\t\t\tsave(record);\n\t\t}\n\t\tconst integrated = git([\"rev-parse\", `refs/leitwerk/reconciled/${operation.id}`]);\n\t\tconst currentHead = git([\"rev-parse\", \"HEAD\"]);\n\t\tconst currentIndex = git([\"write-tree\"]);\n\t\tif (\n\t\t\t![operation.resultHead, integrated].includes(currentHead) ||\n\t\t\t![operation.resultIndex, git([\"rev-parse\", `${integrated}^{tree}`])].includes(currentIndex)\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\t\"Checkout changed during interrupted restoration; local work and recovery refs were retained\",\n\t\t\t);\n\t\tgit([\"update-ref\", `refs/heads/${input.workBranch}`, operation.resultHead, currentHead]);\n\t\tgit([\"read-tree\", operation.resultIndex]);\n\t\trecord.baseline = operation.remote;\n\t\tdelete record.operation;\n\t\tdelete record.joinParent;\n\t\tdelete record.joinIdentity;\n\t\tsave(record);\n\t\tassertIgnoredProtection(git, record.protectedIgnored);\n\t\treturn {\n\t\t\tstatus: \"ready\",\n\t\t\tremoteHead: operation.remote,\n\t\t\theadSha: operation.resultHead,\n\t\t\tchanged: true,\n\t\t};\n\t});\n}\n\n/** Reject ignored-file collisions before a target checkout/rebase can overwrite them. @internal */\nexport function assertReconciliationTargetSafe(\n\tinput: Pick<ReconciliationInput, \"repoPath\" | \"projectKey\">,\n\ttargetSha: string,\n): void {\n\tconst { git, read } = repository(input);\n\tassertIgnoredProtection(git, read()?.protectedIgnored);\n\tif (ignoredPathsCollide(git, ignoredPaths(git), targetSha, `${targetSha}..HEAD`))\n\t\tthrow new Error(\"Target changes collide with ignored files; local files were retained\");\n}\n\n/** Preserve a target rebase as a net local delta when its source lease changes. @internal */\nexport function retainConcurrentRebase(\n\tinput: ReconciliationInput & {\n\t\trebasedHead: string;\n\t\ttargetBase: string;\n\t\tgitIdentity: GitIdentity;\n\t},\n): void {\n\tconst { git, directory, read, save, binding: readBinding } = repository(input);\n\twithLock(directory, () => {\n\t\tconst old = read();\n\t\tif (old?.operation || old?.sourceIntegration)\n\t\t\tthrow new Error(\"Source reconciliation is already in progress\");\n\t\tif (\n\t\t\tgit([\"branch\", \"--show-current\"]) !== input.workBranch ||\n\t\t\tgit([\"rev-parse\", \"HEAD\"]) !== input.rebasedHead ||\n\t\t\tgit([\"status\", \"--porcelain\"])\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\t\"Target rebase changed before source reconciliation; local work was retained\",\n\t\t\t);\n\t\tconst binding = readBinding(input.workBranch);\n\t\tif (!repositoryBindingMatches(old, binding))\n\t\t\tthrow new Error(\"Repository reconciliation binding changed\");\n\t\tconst identity = integrationIdentityEnv(input.gitIdentity);\n\t\tconst id = randomUUID();\n\t\tgit([\"update-ref\", `refs/leitwerk/target-repairs/${id}`, input.rebasedHead]);\n\t\tconst replacement = git(\n\t\t\t[\n\t\t\t\t\"commit-tree\",\n\t\t\t\tgit([\"rev-parse\", `${input.rebasedHead}^{tree}`]),\n\t\t\t\t\"-p\",\n\t\t\t\tinput.baselineSha,\n\t\t\t\t\"-m\",\n\t\t\t\t\"Reconcile target-branch repair\",\n\t\t\t],\n\t\t\tidentity,\n\t\t);\n\t\tgit([\"update-ref\", `refs/leitwerk/target-deltas/${id}`, replacement]);\n\t\t// The original source tree is the merge baseline, not the old target branch.\n\t\t// This preserves developer deletions as well as the agent's conflict resolution.\n\t\tsave({\n\t\t\t...binding,\n\t\t\tbaseline: input.baselineSha,\n\t\t\tremoteSeen: true,\n\t\t\tjoinParent: input.targetBase,\n\t\t\tjoinIdentity: input.gitIdentity,\n\t\t\tprotectedIgnored: old?.protectedIgnored,\n\t\t\tpublicationReceiptSha: old?.publicationReceiptSha,\n\t\t\tsourceIntegration: { previous: input.rebasedHead, replacement },\n\t\t});\n\t});\n}\n\n/** @internal */\nexport function repositoryWorktreeIsDirty(\n\tinput: Pick<ReconciliationInput, \"repoPath\" | \"projectKey\">,\n): boolean {\n\treturn Boolean(repository(input).git([\"status\", \"--porcelain\"]));\n}\n\n/** Capture the baseline before the first implementation, including an unpublished branch. @internal */\nexport function prepareInitialRepository(\n\tinput: Omit<ReconciliationInput, \"baselineSha\">,\n): ReconciliationResult {\n\tconst { git, read, save, directory, binding } = repository(input);\n\twithLock(directory, () => {\n\t\tif (!read())\n\t\t\tsave({\n\t\t\t\t...binding(input.workBranch),\n\t\t\t\tbaseline: git([\"rev-parse\", \"HEAD\"]),\n\t\t\t\tprotectedIgnored: ignoredPaths(git),\n\t\t\t});\n\t});\n\treturn reconcilePublicationRepository(input);\n}\n\n/** Missing branches are allowed only before first publication. @internal */\nexport function reconcilePublicationRepository(\n\tinput: Omit<ReconciliationInput, \"baselineSha\"> & { baselineSha?: string },\n): ReconciliationResult {\n\tconst { git, read, directory } = repository(input);\n\tconst record = read();\n\tconst receipt = readPublicationReceipt(directory);\n\tconst baselineSha =\n\t\trecord?.baseline ??\n\t\tinput.baselineSha ??\n\t\t(receipt?.status === \"accepted\"\n\t\t\t? receipt.candidate\n\t\t\t: (receipt?.expectedHead ??\n\t\t\t\t(receipt?.status === \"attempting\" ? receipt.candidate : undefined)));\n\tassertIgnoredProtection(git, record?.protectedIgnored);\n\tconst remote = git([\"ls-remote\", \"--heads\", \"origin\", `refs/heads/${input.workBranch}`]).split(\n\t\t/\\s+/,\n\t)[0];\n\tif (\n\t\t!remote &&\n\t\t!input.baselineSha &&\n\t\t!record?.remoteSeen &&\n\t\t!record?.operation &&\n\t\t(!receipt || (receipt.status === \"rejected\" && receipt.expectedHead === null))\n\t)\n\t\treturn {\n\t\t\tstatus: \"ready\",\n\t\t\tremoteHead: null,\n\t\t\theadSha: git([\"rev-parse\", \"HEAD\"]),\n\t\t\tchanged: false,\n\t\t};\n\tif (!remote)\n\t\tthrow new Error(\n\t\t\t\"Remote source branch is missing or its publication is uncertain; local work was retained and the branch will not be recreated automatically\",\n\t\t);\n\tif (!baselineSha)\n\t\tthrow new Error(\"Cannot establish the retained work baseline; local work was retained\");\n\treturn reconcileRepository({ ...input, baselineSha });\n}\n\n/** Record only a remotely verified publication, including recovery after a lost reply. @internal */\nexport function recordRepositoryPublication(input: ReconciliationInput, headSha: string): void {\n\tconst { directory, read, save, binding: readBinding } = repository(input);\n\twithLock(directory, () => {\n\t\tconst old = read();\n\t\tif (old?.operation) throw new Error(\"Cannot acknowledge publication during reconciliation\");\n\t\tconst binding = readBinding(input.workBranch);\n\t\tif (!repositoryBindingMatches(old, binding))\n\t\t\tthrow new Error(\"Repository reconciliation binding changed\");\n\t\tsave({\n\t\t\t...binding,\n\t\t\tbaseline: headSha,\n\t\t\tpublicationReceiptSha: headSha,\n\t\t\tremoteSeen: true,\n\t\t\tprotectedIgnored: old?.protectedIgnored,\n\t\t});\n\t});\n}\n\n/** @internal */\nexport const reconciliationPrompt = `Repository synchronization preserves the current remote source branch and unpublished local work. If preparation left a rebase in progress, inspect git status and .git/leitwerk-reconciliation.json. Resolve conflicts preserving both intended changes and the original authors/sign-offs, then git add and GIT_EDITOR=true git rebase --continue until complete. Use the captured operation.identity for the committer when continuing, if present. Do not skip commits, remove the two Leitwerk checkpoint commits, reset, abort, or push. Checkpoint commits will be removed automatically by delivery; do not amend them. After resolving, finish with the turn's required success outcome so delivery can restore the ordinary checkout and request validation. If blocked, use cannot_repair when available or abort_turn otherwise, and retain the checkout. When no rebase is active, perform the requested adjustment and validate the combined result against the current repository instructions before the required success outcome. Never publish without validation after reconciliation.`;\n","import { asUnknownRecord, trimString as normalizeMessage } from \"@leitwerk-dev/domain\";\nimport {\n\ttype Codec,\n\ttype ExternalActionSource,\n\ttype FlowFragmentBuilder,\n\ttype FormDefinition,\n\tflow,\n\thumanTurn,\n\ttype ProcessLauncherDefinition,\n\ttype RepositoryCredentialProject,\n\ttype RepositoryCredentialRequirement,\n\trevisionAction,\n} from \"@leitwerk-dev/process-sdk\";\nimport { codingActionIds, requestRevisionForm } from \"./actions.js\";\nimport {\n\ttype RepositoryChangeState,\n\trepositoryChangeStateCodec,\n} from \"./repository-change-state-internal.js\";\nimport { prepareInitialRepository, reconciliationPrompt } from \"./repository-reconciliation.js\";\nimport { codingPurposes } from \"./settings.js\";\nimport { prepareRepositoryCommitMessageEvidence } from \"./turns/commit-message-evidence.js\";\nimport {\n\tbuildRepositoryCommitMessagesPrompt,\n\tparseRepositoryCommitMessages,\n} from \"./turns/generate-commit-message.js\";\nimport { buildGeneratePlanPrompt } from \"./turns/generate-plan.js\";\nimport { buildImplementPrompt } from \"./turns/implement.js\";\nimport { buildStreamlinedSimplificationPrompt } from \"./turns/simplify-implementation.js\";\n\n/** @public */\nexport type RepositoryChangeParams = object;\n\n/** Server-side policies evaluated at the route boundary. @public */\nexport interface RepositoryChangeWorkflow<TParams> {\n\t/** @deprecated All repository changes use the streamlined graph. @public */\n\tvariant?: \"streamlined\";\n\t/** @public */\n\tmultiRepository?: boolean;\n\t/** @public */\n\tplanDecision?(params: TParams): Promise<{\n\t\t/** @internal */\n\t\tskip: boolean;\n\t\t/** @internal */\n\t\treason: string;\n\t}>;\n\t/** @public */\n\tsimplification?(params: TParams): Promise<{\n\t\t/** @internal */\n\t\tskip: boolean;\n\t\t/** @internal */\n\t\treason: string;\n\t}>;\n\t/** Must recheck the current revision and source before firing. @public */\n\tplanBypassSource?: ExternalActionSource<TParams, RepositoryChangeState, unknown>;\n}\n\n/** @public */\nexport interface RepositoryChangeProcessConfig<TParams extends RepositoryChangeParams> {\n\t/** @public */\n\tprocessId: string;\n\t/** @public */\n\tdisplayName: string;\n\t/** @public */\n\tworkflow?: RepositoryChangeWorkflow<TParams>;\n\t/** @public */\n\tparamsCodec: Codec<TParams>;\n\t/** @public */\n\tlauncher?: ProcessLauncherDefinition<TParams>;\n\t/** @deprecated Publication follows implementation automatically. @public */\n\tfinalizeLabel?: string;\n\t/** @deprecated Publication follows implementation automatically. @public */\n\tfinalizeForm?: FormDefinition;\n\t/** @public */\n\trepositoryCredentials?(input: {\n\t\t/** @public */\n\t\tparams: TParams;\n\t\t/** @internal */\n\t\tprojects: readonly RepositoryCredentialProject[];\n\t}): readonly RepositoryCredentialRequirement[];\n\t/** @public */\n\tpublication: {\n\t\t/** @public */\n\t\tentryTurnId: string;\n\t\t/** @public */\n\t\tfragment: FlowFragmentBuilder<TParams, RepositoryChangeState>;\n\t\t/** @public */\n\t\thappyPath?: readonly string[];\n\t};\n}\n\n/** @public */\nexport function createRepositoryChangeProcess<TParams extends RepositoryChangeParams>(\n\tconfig: RepositoryChangeProcessConfig<TParams>,\n) {\n\tconst tools = [\"read\", \"bash\", \"edit\", \"write\"] as const;\n\tconst planDecision = humanTurn<TParams, RepositoryChangeState>({\n\t\tdescription: \"Review Plan\",\n\t\treviewSemanticRef: \"plan\",\n\t\tnotesFields: [\n\t\t\t{\n\t\t\t\tid: \"message\",\n\t\t\t\tlabel: \"Revision notes\",\n\t\t\t\tplaceholder: \"Describe what the next plan revision should improve\",\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcommentary: \"Approve this plan or request a revision with comments.\",\n\t\tactions: {\n\t\t\t[codingActionIds.approvePlan]: {\n\t\t\t\tlabel: \"Approve plan\",\n\t\t\t\tdescription: \"Accept the current plan and continue into implementation.\",\n\t\t\t\tacceptanceState: \"accepted\",\n\t\t\t\tto: \"implement\",\n\t\t\t\teffect: ({ ctx }) => {\n\t\t\t\t\tif (!ctx.state.semanticEntryRefs.plan?.turnRecordId?.trim())\n\t\t\t\t\t\tthrow new Error(\"No plan is available for approval\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\temit: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"plan_approved\",\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\texternalId: ctx.process.externalId,\n\t\t\t\t\t\t\t\t\tplanRevision: ctx.process.planRevision,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t},\n\t\t\t[codingActionIds.requestRevision]: revisionAction({\n\t\t\t\tlabel: \"Request revision\",\n\t\t\t\tdescription: \"Send the plan back for another draft revision.\",\n\t\t\t\tacceptanceState: \"requires_changes\",\n\t\t\t\tform: requestRevisionForm,\n\t\t\t\tschedulable: true,\n\t\t\t\tto: \"generate_plan\",\n\t\t\t\tqueueTarget: { semanticRef: \"currentPrimaryPathLeaf\" },\n\t\t\t\teffect: ({ input }) => ({\n\t\t\t\t\temit: [\n\t\t\t\t\t\t{ type: \"plan_revision_requested\", data: { message: normalizeMessage(input.message) } },\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t}),\n\t\t},\n\t});\n\tif (config.workflow?.planBypassSource)\n\t\tplanDecision.externalActions = {\n\t\t\tbypass_plan: {\n\t\t\t\tid: \"bypass_plan\",\n\t\t\t\tlabel: \"Skip plan approval\",\n\t\t\t\tsource: config.workflow.planBypassSource,\n\t\t\t\tto: \"implement\",\n\t\t\t\teffect: ({ state, process, event }) => {\n\t\t\t\t\tif ((event as { planRevision?: number }).planRevision !== process.planRevision)\n\t\t\t\t\t\tthrow new Error(\"Stale plan bypass event\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstate: {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\trouting: {\n\t\t\t\t\t\t\t\t...state.routing,\n\t\t\t\t\t\t\t\tplan: { planRevision: process.planRevision, skip: true, reason: \"Jira label\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\temit: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"plan_approved\" as const,\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\tplanRevision: process.planRevision,\n\t\t\t\t\t\t\t\t\tactor: \"system\",\n\t\t\t\t\t\t\t\t\tbypassed: true,\n\t\t\t\t\t\t\t\t\treason: \"Jira label\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\tconst generatePlan = flow\n\t\t.llm<TParams, RepositoryChangeState>(\"generate_plan\")\n\t\t.description(\"Plan\")\n\t\t.executionPurpose(codingPurposes.planning)\n\t\t.tools(\"read\", \"bash\")\n\t\t.askQuestions()\n\t\t.freshPrimary()\n\t\t.buildPrompt(buildGeneratePlanPrompt)\n\t\t.outcomeTool(\"plan_saved\", (tool) =>\n\t\t\ttool\n\t\t\t\t.description(\n\t\t\t\t\t\"Save a finished, implementable plan after resolving design-critical questions. Required investigation and access must be complete. If blocked, use abort_turn. Use ask_questions for operator decisions when available; otherwise decide within the requested scope and document assumptions.\",\n\t\t\t\t)\n\t\t\t\t.requiredString(\"summary\", \"One concise sentence summarizing the proposed plan\")\n\t\t\t\t.requiredStringArray(\n\t\t\t\t\t\"acceptanceCriteria\",\n\t\t\t\t\t\"Requested outcomes for the repository change, without expanding scope\",\n\t\t\t\t)\n\t\t\t\t.routeByState(\n\t\t\t\t\t{\n\t\t\t\t\t\tapproval: {\n\t\t\t\t\t\t\tto: \"plan_decision\",\n\t\t\t\t\t\t\tlabel: \"Approval required\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"When the process policy requires an operator to approve the saved plan.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbypass: {\n\t\t\t\t\t\t\tto: \"implement\",\n\t\t\t\t\t\t\tlabel: \"Skip plan approval\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"When the process policy skips plan approval, for example through the Skip plan approval launcher option.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t({ ctx }) => (ctx.state.routing?.plan?.skip ? \"bypass\" : \"approval\"),\n\t\t\t\t)\n\t\t\t\t.effect(async ({ ctx, event }) => {\n\t\t\t\t\tconst planRevision = ctx.process.planRevision + 1;\n\t\t\t\t\tconst policy = (await config.workflow\n\t\t\t\t\t\t?.planDecision?.(ctx.params)\n\t\t\t\t\t\t.catch(() => ({ skip: false, reason: \"Source unavailable; approval required\" }))) ?? {\n\t\t\t\t\t\tskip: false,\n\t\t\t\t\t\treason: \"Human approval required\",\n\t\t\t\t\t};\n\t\t\t\t\tconst summary = normalizeMessage(event.params.summary);\n\t\t\t\t\tconst acceptanceCriteria = Array.isArray(event.params.acceptanceCriteria)\n\t\t\t\t\t\t? event.params.acceptanceCriteria.filter(\n\t\t\t\t\t\t\t\t(entry): entry is string => typeof entry === \"string\" && entry.trim() !== \"\",\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: [];\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstate: {\n\t\t\t\t\t\t\t...ctx.state,\n\t\t\t\t\t\t\trouting: { ...ctx.state.routing, plan: { ...policy, planRevision } },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tprocessPatch: { planRevision },\n\t\t\t\t\t\tbroadcasts: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"plan.updated\",\n\t\t\t\t\t\t\t\tpayload: {\n\t\t\t\t\t\t\t\t\tplanRevision,\n\t\t\t\t\t\t\t\t\treviewState: policy.skip ? \"accepted\" : \"awaiting_approval\",\n\t\t\t\t\t\t\t\t\tapproved: policy.skip,\n\t\t\t\t\t\t\t\t\tsummary,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\temit: [\n\t\t\t\t\t\t\t...(policy.skip\n\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\ttype: \"plan_approved\" as const,\n\t\t\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t\t\tplanRevision,\n\t\t\t\t\t\t\t\t\t\t\t\tactor: \"system\",\n\t\t\t\t\t\t\t\t\t\t\t\tbypassed: true,\n\t\t\t\t\t\t\t\t\t\t\t\treason: policy.reason,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"plan_saved\",\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\tplanRevision,\n\t\t\t\t\t\t\t\t\tsummary,\n\t\t\t\t\t\t\t\t\tplanMarkdown: ctx.output?.content ?? \"\",\n\t\t\t\t\t\t\t\t\tacceptanceCriteria,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t)\n\t\t.publish(\"plan\");\n\tconst implement = flow\n\t\t.llm<TParams, RepositoryChangeState>(\"implement\")\n\t\t.description(\"Implement\")\n\t\t.waitFor(({ state }) => !!state.productRefs.plan)\n\t\t.executionPurpose(codingPurposes.implementation)\n\t\t.tools(...tools)\n\t\t.freshSeededPrimary()\n\t\t.startFromRoot()\n\t\t.consume(\"plan\")\n\t\t.prepare((ctx) => ({\n\t\t\treconciliation: ctx.repo.all().map((repo) => {\n\t\t\t\tconst identity = asUnknownRecord(\n\t\t\t\t\tctx.projects.find((p) => p.key === repo.key)?.metadata?.[\"leitwerk.gitIdentity\"],\n\t\t\t\t);\n\t\t\t\treturn prepareInitialRepository({\n\t\t\t\t\tprojectKey: repo.key,\n\t\t\t\t\trepoPath: repo.fsPath,\n\t\t\t\t\tworkBranch: repo.workBranch,\n\t\t\t\t\tgitIdentity:\n\t\t\t\t\t\ttypeof identity?.name === \"string\" && typeof identity.email === \"string\"\n\t\t\t\t\t\t\t? { name: identity.name, email: identity.email }\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t});\n\t\t\t}),\n\t\t}))\n\t\t.buildPrompt((ctx) => `${buildImplementPrompt(ctx)}\\n\\n${reconciliationPrompt}`)\n\t\t.outcomeTool(\"implementation_ready\", (tool) =>\n\t\t\ttool\n\t\t\t\t.description(\"Implementation and checks are complete; continue to delivery\")\n\t\t\t\t.routeByState(\n\t\t\t\t\t{\n\t\t\t\t\t\tsimplify: {\n\t\t\t\t\t\t\tto: \"simplify_implementation\",\n\t\t\t\t\t\t\tlabel: \"Simplification enabled\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"When the process policy enables simplification. This is the default unless a launcher option or source policy skips it.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\tskip: {\n\t\t\t\t\t\t\tto: \"generate_commit_message\",\n\t\t\t\t\t\t\tlabel: \"Skip simplification\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"When simplification is skipped, for example through the Skip simplification launcher option or the leitwerk-skip-simplification source label.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t({ ctx }) => (ctx.state.routing?.simplification?.skip ? \"skip\" : \"simplify\"),\n\t\t\t\t)\n\t\t\t\t.effect(async ({ ctx }) => ({\n\t\t\t\t\tstate: {\n\t\t\t\t\t\t...ctx.state,\n\t\t\t\t\t\trouting: {\n\t\t\t\t\t\t\t...ctx.state.routing,\n\t\t\t\t\t\t\tsimplification: ctx.state.routing?.simplification ??\n\t\t\t\t\t\t\t\t(await config.workflow?.simplification?.(ctx.params)) ?? {\n\t\t\t\t\t\t\t\t\tskip: false,\n\t\t\t\t\t\t\t\t\treason: \"Simplification enabled by default\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t)\n\t\t.publish(\"implementation-summary\");\n\tconst simplify = flow\n\t\t.llm<TParams, RepositoryChangeState>(\"simplify_implementation\")\n\t\t.description(\"Simplify\")\n\t\t.executionPurpose(codingPurposes.review)\n\t\t.tools(\"read\", \"bash\")\n\t\t.rootBranchReview()\n\t\t.startFromProductBranch(\"simplification-plan\")\n\t\t.buildPrompt(buildStreamlinedSimplificationPrompt)\n\t\t.publish(\"simplification-plan\")\n\t\t.to(\"apply_simplification\");\n\tconst applySimplification = flow\n\t\t.llm<TParams, RepositoryChangeState>(\"apply_simplification\")\n\t\t.description(\"Apply simplification\")\n\t\t.executionPurpose(codingPurposes.implementation)\n\t\t.tools(...tools)\n\t\t.freshSeededPrimary()\n\t\t.consume(\"plan\")\n\t\t.consume(\"simplification-plan\")\n\t\t.buildPrompt(\n\t\t\t(\n\t\t\t\tctx,\n\t\t\t) => `Apply justified simplifications to each repository, preserving the accepted plan and behavior. Rerun the required checks. Empty findings require no edits. Leave changes uncommitted for delivery.\n\nAccepted plan:\n${ctx.input.plan}\n\nFindings by repository:\n${ctx.input[\"simplification-plan\"]}`,\n\t\t)\n\t\t.publish(\"implementation-summary\")\n\t\t.to(\"generate_commit_message\");\n\tconst generateCommitMessage = flow\n\t\t.llm<TParams, RepositoryChangeState>(\"generate_commit_message\")\n\t\t.description(\"Write Commit Message\")\n\t\t.executionPurpose(codingPurposes.implementation)\n\t\t.tools(\"read\", \"grep\", \"find\", \"ls\")\n\t\t.rootBranchReview()\n\t\t.startFromRoot()\n\t\t.consume(\"plan\")\n\t\t.consume(\"implementation-summary\")\n\t\t.prepare(prepareRepositoryCommitMessageEvidence)\n\t\t.buildPrompt(buildRepositoryCommitMessagesPrompt)\n\t\t.publish(\"commit-message\")\n\t\t.to(config.publication.entryTurnId)\n\t\t.state(({ ctx }) => ({\n\t\t\t...ctx.state,\n\t\t\tfinalization: {\n\t\t\t\t...ctx.state.finalization,\n\t\t\t\tcommitMessages: parseRepositoryCommitMessages(\n\t\t\t\t\tctx.output?.content,\n\t\t\t\t\tctx.projects.map((p) => p.key),\n\t\t\t\t),\n\t\t\t},\n\t\t}));\n\tconst builder = flow\n\t\t.process<TParams, RepositoryChangeState>(config.processId)\n\t\t.displayName(config.displayName)\n\t\t.entry(\"generate_plan\")\n\t\t.happyPath(\n\t\t\t\"generate_plan\",\n\t\t\t\"implement\",\n\t\t\t\"simplify_implementation\",\n\t\t\t\"apply_simplification\",\n\t\t\t\"generate_commit_message\",\n\t\t\t...(config.publication.happyPath ?? [config.publication.entryTurnId]),\n\t\t)\n\t\t.piConfig(config.workflow?.multiRepository ? {} : { sessionCwdTemplate: \"{{{projectKey}}}\" })\n\t\t.codecs({ params: config.paramsCodec, state: repositoryChangeStateCodec })\n\t\t.initialState(() => repositoryChangeStateCodec.parse({}))\n\t\t.turn(generatePlan)\n\t\t.turn({ id: \"plan_decision\", definition: planDecision })\n\t\t.turn(implement)\n\t\t.turn(simplify)\n\t\t.turn(applySimplification)\n\t\t.turn(generateCommitMessage)\n\t\t.use(config.publication.fragment);\n\tif (config.repositoryCredentials) builder.repositoryCredentials(config.repositoryCredentials);\n\tif (config.launcher) builder.launcher(config.launcher);\n\treturn {\n\t\t/** @public */\n\t\tprocess: builder.define(),\n\t};\n}\n","import type { Codec, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\nimport { parseStructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\n/** @public */\nexport interface RepositoryChangeFinalizationState {\n\t/** @public */\n\tgeneratedCommitMessage: string | null;\n\t/** Messages keyed by process project key. @public */\n\tcommitMessages?: Record<string, string>;\n}\n\n/** @public */\nexport interface RepositoryChangeState extends StructuralProcessState {\n\t/** @public */\n\tfinalization: RepositoryChangeFinalizationState;\n\t/** Completed routing decisions survive recovery. @public */\n\trouting?: {\n\t\t/** @public */\n\t\tplan?: {\n\t\t\t/** @internal */\n\t\t\tplanRevision: number;\n\t\t\t/** @internal */ skip: boolean;\n\t\t\t/** @internal */ reason: string;\n\t\t};\n\n\t\t/** @public */\n\t\tsimplification?: {\n\t\t\t/** @internal */\n\t\t\tskip: boolean;\n\t\t\t/** @internal */ reason: string;\n\t\t};\n\t};\n\t/** Namespaced state owned by a caller-supplied publication workflow. */\n\n\t/** @public */\n\textensionState?: Record<string, unknown>;\n}\n\nfunction toRecord(value: unknown): Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null ? (value as Record<string, unknown>) : {};\n}\n\nfunction parseFinalizationState(value: unknown): RepositoryChangeFinalizationState {\n\tconst record = toRecord(value);\n\treturn {\n\t\tgeneratedCommitMessage:\n\t\t\ttypeof record.generatedCommitMessage === \"string\" ? record.generatedCommitMessage : null,\n\t\t...(record.commitMessages\n\t\t\t? {\n\t\t\t\t\tcommitMessages: Object.fromEntries(\n\t\t\t\t\t\tObject.entries(toRecord(record.commitMessages)).filter(\n\t\t\t\t\t\t\t(entry): entry is [string, string] => typeof entry[1] === \"string\",\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t}\n\t\t\t: {}),\n\t};\n}\n\n/** @internal */\nexport const repositoryChangeStateCodec: Codec<RepositoryChangeState> = {\n\tparse(value) {\n\t\tconst record = toRecord(value);\n\t\treturn {\n\t\t\t...parseStructuralProcessState(record),\n\t\t\tfinalization: parseFinalizationState(record.finalization),\n\t\t\textensionState: toRecord(record.extensionState),\n\t\t\trouting: toRecord(record.routing) as RepositoryChangeState[\"routing\"],\n\t\t};\n\t},\n\tserialize(value) {\n\t\treturn value;\n\t},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAM,kBAAkB;AAAA;AAAA,EAE9B,aAAa;AAAA;AAAA,EAEb,iBAAiB;AAAA;AAAA,EAEjB,WAAW;AAAA;AAAA,EAEX,UAAU;AAAA;AAAA,EAEV,cAAc;AAAA;AAAA,EAEd,sBAAsB;AAAA;AAAA,EAEtB,eAAe;AAAA;AAAA,EAEf,gBAAgB;AACjB;AAEA,SAAS,UAAU,IAAY,OAAe,OAAe,aAAqC;AACjG,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,MACP,EAAE,IAAI,WAAW,OAAO,MAAM,YAAY,eAAe,MAAM,UAAU,MAAM,YAAY;AAAA,IAC5F;AAAA,IACA,aAAa;AAAA,EACd;AACD;AAGO,IAAM,sBAAsB;AAAA,EAClC,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACD;AAEO,IAAM,2BAA2B;AAAA,EACvC,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACD;AAEO,IAAM,mBAAmC;AAAA,EAC/C,I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AAmB,EACxB,KAAK,qBAAqB,EAC1B,IAAI,OAAO,YAAY,QAAQ;AACjC,MAAI,OAAO,sBAAuB,SAAQ,sBAAsB,OAAO,qBAAqB;AAC5F,MAAI,OAAO,SAAU,SAAQ,SAAS,OAAO,QAAQ;AACrD,SAAO;AAAA;AAAA,IAEN,SAAS,QAAQ,OAAO;AAAA,EACzB;AACD;","names":["process"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/turns/implement.ts"],"sourcesContent":["import type { FlowPromptContext, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport function buildImplementPrompt(\n\tctx: Pick<\n\t\tFlowPromptContext<unknown, StructuralProcessState, \"plan\">,\n\t\t\"prompts\" | \"input\" | \"repo\"\n\t>,\n): string {\n\treturn `Implement this requested change:\n${ctx.prompts.initial}\n\nRepository checkouts: ${ctx.repo\n\t\t.all()\n\t\t.map((repo) => `${repo.key}: ${repo.fsPath}`)\n\t\t.join(\"; \")}\n\nFollow this plan:\n${ctx.input.plan}\n\nRules:\n- keep going until the change is complete; do any necessary additional passes without asking\n- make repository changes only inside the current working directory\n- run file edits, Git commands, and checks in the appropriate checkout\n- follow each repository’s instructions and validate every affected repository\n- leave changes uncommitted; delivery owns commits and pushes\n- do not read from or write to any original source repository path outside the process workspace\n- keep the implementation coherent and complete\n- keep the number of changed files small\n- when documenting, be sparse. Do not narrate the implementation or maintain a prose inventory of tests, helpers, internal environment variables, or cleanup mechanics.\n- publish the implementation summary when done`;\n}\n"],"mappings":";AAGO,SAAS,qBACf,KAIS;AACT,SAAO;AAAA,EACN,IAAI,QAAQ,OAAO;AAAA;AAAA,wBAEG,IAAI,KACzB,IAAI,EACJ,IAAI,CAAC,SAAS,GAAG,KAAK,GAAG,KAAK,KAAK,MAAM,EAAE,EAC3C,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA,EAGX,IAAI,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAahB;","names":[]}