@leitwerk-dev/coding 0.5.10 → 0.5.12

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 (32) hide show
  1. package/README.md +1 -0
  2. package/dist/{chunk-JL53OV5M.js → chunk-5M3DTAVU.js} +25 -9
  3. package/dist/chunk-5M3DTAVU.js.map +1 -0
  4. package/dist/{chunk-E3DB4TIZ.js → chunk-DVQWH5SN.js} +22 -2
  5. package/dist/chunk-DVQWH5SN.js.map +1 -0
  6. package/dist/{chunk-VG6XF3OK.js → chunk-GIWVCTYT.js} +20 -14
  7. package/dist/chunk-GIWVCTYT.js.map +1 -0
  8. package/dist/finalization-git-internal.d.ts +2 -0
  9. package/dist/finalization-git-internal.d.ts.map +1 -1
  10. package/dist/finalization-git.js +2 -2
  11. package/dist/index.js +2 -2
  12. package/dist/{repository-change-launch-internal-CP2jJJCR.d.ts → repository-change-launch-internal-D_QWCQAN.d.ts} +1 -1
  13. package/dist/{repository-change-process-DbcnkzLw.d.ts → repository-change-process-Dc-jsbCL.d.ts} +2 -0
  14. package/dist/repository-change-process.d.ts +2 -0
  15. package/dist/repository-change-process.d.ts.map +1 -1
  16. package/dist/repository-change-publication.d.ts +4 -0
  17. package/dist/repository-change-publication.d.ts.map +1 -1
  18. package/dist/repository-change-publication.js +41 -33
  19. package/dist/repository-change-publication.js.map +1 -1
  20. package/dist/repository-reconciliation.d.ts +15 -13
  21. package/dist/repository-reconciliation.d.ts.map +1 -1
  22. package/dist/submodule-staging.d.ts +11 -0
  23. package/dist/submodule-staging.d.ts.map +1 -0
  24. package/package.json +5 -5
  25. package/src/finalization-git-internal.ts +19 -17
  26. package/src/repository-change-process.ts +24 -6
  27. package/src/repository-change-publication.ts +41 -33
  28. package/src/repository-reconciliation.ts +17 -27
  29. package/src/submodule-staging.ts +27 -0
  30. package/dist/chunk-E3DB4TIZ.js.map +0 -1
  31. package/dist/chunk-JL53OV5M.js.map +0 -1
  32. package/dist/chunk-VG6XF3OK.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/repository-change-publication.ts","../src/repository-rebase/git.ts","../src/repository-rebase/policy.ts","../src/repository-rebase/prompt.ts","../src/pull-request-publication-internal.ts"],"sourcesContent":["import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\ttype AutomaticOutcomeBuilder,\n\ttype ExtensionProcessDefinition,\n\ttype ExternalActionSource,\n\ttype FlowAutomaticRunContext,\n\tflow,\n\ttype ServerExtensionAPI,\n} from \"@leitwerk-dev/process-sdk\";\nimport {\n\tcommitAndPushWorkBranch,\n\ttype GitIdentity,\n\trepositoryHasChanges,\n} from \"./finalization-git.js\";\nimport { RemoteBranchChangedError } from \"./finalization-git-internal.js\";\nimport type { RepositoryChangeState } from \"./repository-change-state.js\";\nimport {\n\tConcurrentRebaseSourceError,\n\thasPreparedRebase,\n\tpublishRebase,\n\tstartRebase,\n} from \"./repository-rebase/git.js\";\nimport { type ConflictEvidence, conflictKey, validateConflict } from \"./repository-rebase/index.js\";\nimport { rebasePrompt } from \"./repository-rebase/prompt.js\";\nimport {\n\treconcilePublicationRepository,\n\treconciliationPrompt,\n\trecordRepositoryPublication,\n\trepositoryWorktreeIsDirty,\n\tretainConcurrentRebase,\n} from \"./repository-reconciliation.js\";\nimport { codingPurposes } from \"./settings.js\";\n\nexport {\n\tcreatePullRequestChangeProcess,\n\tpullRequestPublicationDefaults,\n\tresolvePullRequestGitIdentity,\n} from \"./pull-request-publication-internal.js\";\n\n/** @public */\nexport interface PublicationRequest {\n\t/** @public */\n\tnumber: number;\n\n\t/** @public */\n\thtml_url: string;\n\n\t/** @public */\n\tmerged: boolean;\n\n\t/** @public */\n\tmerge_commit_sha?: string | null;\n}\n\n/** @public */\nexport interface PublicationPipeline {\n\t/** @public */\n\tnumber: number;\n\n\t/** @public */\n\tstatus: string;\n\n\t/** @public */\n\t[key: string]: unknown;\n}\n\n/** @public */\nexport interface PublicationParams {\n\t/** @public */\n\towner: string;\n\n\t/** @public */\n\trepo: string;\n\n\t/** @public */\n\tworkBranch: string;\n\n\t/** @public */\n\tbaseBranch: string;\n}\n\n/** Narrow process params to a resolved repository before publication. @public */\nexport function requirePublicationParams<P>(params: P): P & PublicationParams {\n\tconst value = asUnknownRecord(params);\n\tfor (const key of [\"owner\", \"repo\", \"workBranch\", \"baseBranch\"])\n\t\tif (typeof value?.[key] !== \"string\" || !value[key])\n\t\t\tthrow new Error(\"Repository binding is not resolved\");\n\treturn params as P & PublicationParams;\n}\n\n/** @public */\nexport type PublicationContext<P> = FlowAutomaticRunContext<P, RepositoryChangeState>;\n\n/** Remote reconciliation has no worker checkout or filesystem access. @public */\nexport type PublicationReconciliationContext<P> = Pick<\n\tPublicationContext<P>,\n\t\"process\" | \"projects\" | \"params\" | \"state\" | \"callIntegrationTool\"\n>;\n\n/** @public */\nexport type PublicationEvidence = (\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"feedback\";\n\n\t\t\t/** @public */\n\t\t\tfeedbackIds: PublicationFeedbackId[];\n\n\t\t\t/** @public */\n\t\t\tconversationCursor: number;\n\n\t\t\t/** @public */\n\t\t\treviewCursor: number;\n\n\t\t\t/** @public */\n\t\t\tinlineCursor: number;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"failure\";\n\n\t\t\t/** @public */\n\t\t\tpipeline: PublicationPipeline;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"conflict\";\n\n\t\t\t/** @public */\n\t\t\tconflict: ConflictEvidence;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"terminal\";\n\n\t\t\t/** @public */\n\t\t\trequest: PublicationRequest;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"cancelled\";\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"observed\";\n\t }\n) & {\n\t/** @public */\n\tobservationKey?: string;\n\t/** Current provider source revision. @internal */ remoteHeadSha?: string;\n\t/** Coordinated repository key. @public */ projectKey?: string;\n};\n\n/** @public */\nexport interface PublicationSource<P> {\n\t/** @public */\n\tid: string;\n\n\t/** @public */\n\tkind: \"feedback\" | \"failure\" | \"conflict\" | \"terminal\" | \"cancelled\" | \"observation\";\n\n\t/** @public */\n\toperatorId?: string;\n\n\t/** @public */\n\tlabel: string;\n\n\t/** @public */\n\tsource: ExternalActionSource<P, RepositoryChangeState, unknown>;\n\n\t/** @public */\n\tenabled?(params: P, state: RepositoryChangeState): boolean;\n\n\t/** @public */\n\tread(input: {\n\t\t/** @public */\n\t\tparams: P;\n\n\t\t/** @public */\n\t\tstate: RepositoryChangeState;\n\n\t\t/** @public */\n\t\tevent: unknown;\n\t}): PublicationEvidence;\n}\n\n/** @public */\nexport interface RepositoryChangePublicationAdapter<P> {\n\t/** Optional server maintenance uses existing business turns and adds no worker positions. @public */\n\tmaintenance?: {\n\t\t/** @public */ source: ExternalActionSource<\n\t\t\tP,\n\t\t\tRepositoryChangeState,\n\t\t\tPublicationMaintenanceEvent\n\t\t>;\n\t\t/** @public */ ownershipTool: string;\n\t\t/** @public */ register(\n\t\t\tapi: ServerExtensionAPI,\n\t\t\tprocess: ExtensionProcessDefinition<P, RepositoryChangeState>,\n\t\t): void;\n\t};\n\t/** @public */\n\tnamespace: string;\n\t/** Reconcile a single-repository no-change outcome. @public */\n\tunchanged?(ctx: PublicationContext<P>): Promise<void>;\n\t/** Optional coordinated repositories; each retains independent publication state. @public */\n\trepositories?(params: P): readonly {\n\t\t/** @internal */\n\t\tkey: string;\n\t\t/** @internal */\n\t\tparams: P & PublicationParams;\n\t}[];\n\t/** Reconcile remote terminal state before new writes or source cancellation. @public */\n\tobserveTerminal?(\n\t\tctx: PublicationContext<P>,\n\t\tcurrent: PublicationState,\n\t): Promise<PublicationRequest | null>;\n\n\t/** @public */\n\tsourceCancelled?(ctx: PublicationReconciliationContext<P>): Promise<boolean>;\n\n\t/** @public */\n\treconcileAll?(\n\t\tctx: PublicationReconciliationContext<P>,\n\t\tresults: readonly {\n\t\t\t/** @internal */\n\t\t\tkey: string;\n\t\t\t/** @internal */\n\t\t\tcurrent: PublicationState;\n\t\t}[],\n\t\tcancelled: boolean,\n\t): Promise<void>;\n\n\t/** @public */\n\tlabel: string;\n\n\t/** @public */\n\tids: {\n\t\t/** @public */\n\t\tdeliver: string;\n\n\t\t/** @public */\n\t\tfeedback: string;\n\n\t\t/** @public */\n\t\tciRepair: string;\n\n\t\t/** @public */\n\t\toperator: string;\n\t};\n\n\t/** @public */\n\ttools: {\n\t\t/** @public */\n\t\tdelivery: readonly string[];\n\n\t\t/** @public */\n\t\tfeedback: readonly string[];\n\n\t\t/** @public */\n\t\tci: readonly string[];\n\t};\n\n\t/** @public */\n\tsources: readonly PublicationSource<P>[];\n\n\t/** @public */\n\tidentity(ctx: PublicationContext<P>): Promise<GitIdentity>;\n\n\t/** @public */\n\tensureRequest(ctx: PublicationContext<P>): Promise<PublicationRequest>;\n\n\t/** @public */\n\treconcileTerminal(\n\t\tctx: PublicationReconciliationContext<P>,\n\t\tcurrent: PublicationState,\n\t\trequest: PublicationRequest,\n\t): Promise<void>;\n\n\t/** @public */\n\tlinkIssue(ctx: PublicationContext<P>, current: PublicationState): Promise<void>;\n\n\t/** @public */\n\tacknowledge(ctx: PublicationContext<P>, current: PublicationState): Promise<void>;\n\n\t/** @public */\n\treply(ctx: PublicationContext<P>, current: PublicationState): Promise<void>;\n\n\t/** @public */\n\tafterRebase(ctx: PublicationContext<P>, current: PublicationState): Promise<void>;\n\n\t/** @public */\n\thead(ctx: PublicationContext<P>, current: PublicationState): Promise<string>;\n\n\t/** @public */\n\tprompt(kind: \"feedback\" | \"ci\", current: PublicationState): string;\n\n\t/** @public */\n\tcommitMessage(kind: \"feedback\" | \"ci\"): string;\n}\n\n/** @public */\nexport interface PublicationMaintenanceEvent {\n\t/** @public */\n\tstate: RepositoryChangeState;\n}\n\n/** @public */\nexport interface FeedbackDeliveryResult {\n\t/** @public */\n\tpublished: boolean;\n\t/** @public */\n\tsummary: string;\n}\n\n/** @public */\nexport type PublicationFeedbackId = {\n\t/** @public */\n\tkind: \"conversation\" | \"review\" | \"inline\";\n\n\t/** @public */\n\tid: number;\n\n\t/** @public */\n\tdiscussionId?: string;\n};\n\n/** @public */\ntype AdjustmentInvocation = {\n\t/** @public */\n\torigin: \"feedback\" | \"ci\" | \"rebase\";\n\n\t/** @public */\n\tpublishRequired: boolean;\n\t/** Operator-facing no-change diagnosis retained until delivery. @internal */\n\tsummary?: string;\n};\n\n/** @public */\nexport interface DeliveryState {\n\t/** Feedback delivery retained until the server acknowledges the batch. @public */\n\tfeedbackResult?: FeedbackDeliveryResult | null;\n\t/** @public */\n\tstage: \"not_started\" | \"branch_published\" | \"pull_request_ready\" | \"awaiting\";\n\n\t/** @public */\n\tissueLinked: boolean;\n\n\t/** @public */\n\tadjustment: AdjustmentInvocation | null;\n\n\t/** @public */\n\tterminalPullRequest: PublicationRequest | null;\n}\n\n/** @public */\nexport interface PublicationState {\n\t/** Maintenance was stopped for this MR; it remains open and contributes a partial result. @public */ stopped?: boolean;\n\t/** Repository had no change at first publication. @public */ noChanges?: boolean;\n\n\t/** @public */\n\tlastConflictKey?: string | null;\n\n\t/** @public */\n\tconflict?: ConflictEvidence | null;\n\n\t/** @public */\n\trepairReason?: \"feedback\" | \"ci\" | \"rebase\";\n\t/** Staged repair retained when another maintained MR interrupts the worker. @public */\n\trepairPending?: boolean;\n\n\t/** @public */\n\theadSha: string | null;\n\n\t/** Baseline retained until the worker reconciles its unpublished delta. @internal */\n\tworkBaselineSha?: string | null;\n\t/** Historical publication receipt, not an eligibility condition. @internal */\n\tlastPublishedHeadSha?: string | null;\n\t/** Combined tree needs validation before publication. @internal */\n\treconciliationRequired?: boolean;\n\t/** Bound automatic reconciliation loops under continuously moving branches. @internal */\n\treconciliationCycles?: number;\n\n\t/** @public */\n\tprNumber: number | null;\n\n\t/** @public */\n\tprUrl: string | null;\n\n\t/** @public */\n\tconversationCursor: number;\n\n\t/** @public */\n\treviewCursor: number;\n\n\t/** @public */\n\tinlineCursor: number;\n\n\t/** @public */\n\tfeedbackIds: PublicationFeedbackId[];\n\n\t/** @public */\n\tpipeline: PublicationPipeline | null;\n\n\t/** @public */\n\tciRecoveryCycles: number;\n\n\t/** @public */\n\tdelivery: DeliveryState;\n\n\t/** @public */\n\tobservationKey?: string;\n\n\t/** @public */\n\tpendingEvidence?: PublicationEvidence | null;\n}\n\nconst initialDeliveryState: DeliveryState = {\n\tstage: \"not_started\",\n\tissueLinked: false,\n\tadjustment: null,\n\tterminalPullRequest: null,\n};\n\nconst initialPublicationState: PublicationState = {\n\theadSha: null,\n\tprNumber: null,\n\tprUrl: null,\n\tconversationCursor: 0,\n\treviewCursor: 0,\n\tinlineCursor: 0,\n\tfeedbackIds: [],\n\tpipeline: null,\n\tciRecoveryCycles: 0,\n\tdelivery: initialDeliveryState,\n};\n\n/** @public */\nexport const publicationObject = (value: unknown) => asUnknownRecord(value) ?? {};\n\n/** Shared coordination metadata for worker publication and server maintenance. @internal */\nexport function createPublicationSelection(namespace: () => string) {\n\treturn {\n\t\t/** @internal */\n\t\tactiveKey: (state: RepositoryChangeState) =>\n\t\t\tpublicationObject(state.extensionState?.[`${namespace()}.coordination`]).activeKey as\n\t\t\t\t| string\n\t\t\t\t| undefined,\n\t\t/** @internal */\n\t\tselect: (state: RepositoryChangeState, key: string): RepositoryChangeState => ({\n\t\t\t...state,\n\t\t\textensionState: {\n\t\t\t\t...state.extensionState,\n\t\t\t\t[`${namespace()}.coordination`]: { activeKey: key },\n\t\t\t},\n\t\t}),\n\t};\n}\n\n/** @internal */\nexport const publicationFinished = (current: PublicationState): boolean =>\n\t!!(current.stopped || current.noChanges || current.delivery.terminalPullRequest);\n\n/** @public */\nexport function readPublicationState(\n\tstate: RepositoryChangeState,\n\tnamespace: string,\n): PublicationState {\n\tconst stored = publicationObject(publicationObject(state.extensionState)[namespace]);\n\treturn {\n\t\t...initialPublicationState,\n\t\t...stored,\n\t\tdelivery: {\n\t\t\t...initialDeliveryState,\n\t\t\t...publicationObject(stored.delivery),\n\t\t},\n\t} as PublicationState;\n}\n\n/** @public */\nexport function patchPublicationState(\n\tstate: RepositoryChangeState,\n\tnamespace: string,\n\tpatch: Partial<Omit<PublicationState, \"delivery\">> & {\n\t\t/** @public */\n\t\tdelivery?: Partial<DeliveryState>;\n\t},\n): RepositoryChangeState {\n\tconst current = readPublicationState(state, namespace);\n\treturn {\n\t\t...state,\n\t\textensionState: {\n\t\t\t...state.extensionState,\n\t\t\t[namespace]: {\n\t\t\t\t...current,\n\t\t\t\t...patch,\n\t\t\t\tdelivery: { ...current.delivery, ...patch.delivery },\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** @public */\nexport function applyPublicationEvidence(\n\tparams: unknown,\n\tcurrent: PublicationState,\n\tevidence: PublicationEvidence,\n\tcountFailure = true,\n): PublicationState {\n\tif (evidence.observationKey !== undefined)\n\t\tcurrent = { ...current, observationKey: evidence.observationKey };\n\tif (evidence.remoteHeadSha && evidence.remoteHeadSha !== current.headSha)\n\t\tcurrent = {\n\t\t\t...current,\n\t\t\tworkBaselineSha: current.workBaselineSha ?? current.headSha,\n\t\t\tlastPublishedHeadSha: current.lastPublishedHeadSha ?? current.headSha,\n\t\t\theadSha: evidence.remoteHeadSha,\n\t\t\tpipeline: null,\n\t\t};\n\tswitch (evidence.kind) {\n\t\tcase \"feedback\": {\n\t\t\tconst { kind: _, ...batch } = evidence;\n\t\t\treturn { ...current, ...batch, repairReason: \"feedback\" };\n\t\t}\n\t\tcase \"failure\":\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\trepairReason: \"ci\",\n\t\t\t\tpipeline: evidence.pipeline,\n\t\t\t\tciRecoveryCycles: current.ciRecoveryCycles + (countFailure ? 1 : 0),\n\t\t\t};\n\t\tcase \"conflict\": {\n\t\t\tconst repository = requirePublicationParams(params);\n\t\t\tconst conflict = validateConflict(\n\t\t\t\tevidence.conflict,\n\t\t\t\t{\n\t\t\t\t\towner: repository.owner,\n\t\t\t\t\trepo: repository.repo,\n\t\t\t\t\tprNumber: current.prNumber ?? 0,\n\t\t\t\t\theadSha: current.headSha ?? \"\",\n\t\t\t\t\theadBranch: repository.workBranch,\n\t\t\t\t\tbaseBranch: repository.baseBranch,\n\t\t\t\t},\n\t\t\t\tcurrent.lastConflictKey,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\tconflict,\n\t\t\t\tlastConflictKey: conflictKey(conflict),\n\t\t\t\trepairReason: \"rebase\",\n\t\t\t};\n\t\t}\n\t\tcase \"terminal\":\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\tdelivery: { ...current.delivery, terminalPullRequest: evidence.request },\n\t\t\t};\n\t\tdefault:\n\t\t\treturn current;\n\t}\n}\nfunction deliveryProgress(value: PublicationState, label: string, activeStepId?: string) {\n\tconst delivery = value.delivery;\n\tconst step = (id: string, label: string, done: boolean) => ({\n\t\tid,\n\t\tlabel,\n\t\tstatus: (activeStepId === id ? \"in_progress\" : done ? \"completed\" : \"incomplete\") as\n\t\t\t| \"in_progress\"\n\t\t\t| \"completed\"\n\t\t\t| \"incomplete\",\n\t});\n\tconst adjustmentHandled =\n\t\tdelivery.adjustment === null && delivery.stage === \"awaiting\" && value.headSha !== null;\n\treturn {\n\t\ttitle: \"Delivery progress\",\n\t\tsteps: [\n\t\t\tstep(\"publish_branch\", \"Publish work branch\", value.headSha !== null),\n\t\t\tstep(\"open_pr\", \"Create or find pull request\", value.prNumber !== null),\n\t\t\tstep(\"link_issue\", \"Link source issue when applicable\", delivery.issueLinked),\n\t\t\tstep(\"publish_adjustment\", \"Publish an adjustment when applicable\", adjustmentHandled),\n\t\t\tstep(\n\t\t\t\t\"reply_feedback\",\n\t\t\t\t\"Acknowledge or reply to feedback when applicable\",\n\t\t\t\tvalue.feedbackIds.length === 0,\n\t\t\t),\n\t\t\tstep(\"await_evidence\", \"Await external evidence\", delivery.stage === \"awaiting\"),\n\t\t\tstep(\n\t\t\t\t\"reconcile_terminal\",\n\t\t\t\t\"Reconcile terminal pull request\",\n\t\t\t\tdelivery.terminalPullRequest !== null,\n\t\t\t),\n\t\t],\n\t\t...(value.prNumber && value.prUrl\n\t\t\t? {\n\t\t\t\t\tlinks: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: `${label}-pr-${value.prNumber}`,\n\t\t\t\t\t\t\tlabel: `${label} #${value.prNumber}`,\n\t\t\t\t\t\t\turl: value.prUrl,\n\t\t\t\t\t\t\tkind: \"pull_request\" as const,\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/** @public */\nexport function createRepositoryChangePublication<P>(\n\tadapter: RepositoryChangePublicationAdapter<P>,\n) {\n\tconst ids = adapter.ids;\n\tconst publication = flow.fragment<P, RepositoryChangeState>(`${adapter.namespace}-publication`);\n\tconst { activeKey, select } = createPublicationSelection(() => adapter.namespace);\n\tconst namespace = (state: RepositoryChangeState) =>\n\t\tadapter.repositories ? `${adapter.namespace}:${activeKey(state)}` : adapter.namespace;\n\tconst remote = (state: RepositoryChangeState) => readPublicationState(state, namespace(state));\n\tconst repositoryContext = (ctx: PublicationContext<P>): PublicationContext<P> => {\n\t\tif (!adapter.repositories) return ctx;\n\t\tconst selected = adapter\n\t\t\t.repositories(ctx.params)\n\t\t\t.find((repo) => repo.key === activeKey(ctx.state));\n\t\tif (!selected) throw new Error(\"Missing coordinated repository selection\");\n\t\treturn {\n\t\t\t...ctx,\n\t\t\tparams: selected.params,\n\t\t\trepo: { ...ctx.repo, get: (key) => ctx.repo.get(key === \"repo\" ? selected.key : key) },\n\t\t\tcallIntegrationTool: (name, args) =>\n\t\t\t\tctx.callIntegrationTool(name, { ...args, projectKey: selected.key }),\n\t\t};\n\t};\n\tconst patchRemote = (\n\t\tstate: RepositoryChangeState,\n\t\tpatch: Partial<Omit<PublicationState, \"delivery\">> & { delivery?: Partial<DeliveryState> },\n\t) => patchPublicationState(state, namespace(state), patch);\n\tasync function commitWorkBranch(\n\t\tctx: PublicationContext<P>,\n\t\tcommitMessage: string,\n\t\texpectedRemoteHead = remote(ctx.state).headSha,\n\t) {\n\t\tconst repo = ctx.repo.get(\"repo\");\n\t\tconst gitIdentity = await adapter.identity(ctx);\n\t\tif (adapter.maintenance)\n\t\t\tawait ctx.callIntegrationTool(adapter.maintenance.ownershipTool, { projectKey: repo.key });\n\t\treturn commitAndPushWorkBranch({\n\t\t\trepoPath: repo.fsPath,\n\t\t\tprojectKey: repo.key,\n\t\t\tworkBranch: repo.workBranch,\n\t\t\tcommitMessage,\n\t\t\tgitIdentity,\n\t\t\texpectedRemoteHead,\n\t\t});\n\t}\n\tasync function reconcile(ctx: PublicationContext<P>, current: PublicationState) {\n\t\tconst repo = ctx.repo.get(\"repo\");\n\t\treturn reconcilePublicationRepository({\n\t\t\tprojectKey: repo.key,\n\t\t\trepoPath: repo.fsPath,\n\t\t\tworkBranch: repo.workBranch,\n\t\t\tbaseBranch: repo.baseBranch,\n\t\t\tbaselineSha: current.workBaselineSha ?? current.headSha ?? undefined,\n\t\t\tgitIdentity: await adapter.identity(ctx),\n\t\t});\n\t}\n\tconst runRepository = async (ctx: PublicationContext<P>) => {\n\t\tlet current = remote(ctx.state);\n\t\tconst update = (patch: Parameters<typeof patchRemote>[1]) => {\n\t\t\tcurrent = { ...current, ...patch, delivery: { ...current.delivery, ...patch.delivery } };\n\t\t};\n\t\tconst acknowledgePublication = (headSha: string, changed: boolean) => {\n\t\t\tupdate({\n\t\t\t\theadSha,\n\t\t\t\tworkBaselineSha: headSha,\n\t\t\t\tlastPublishedHeadSha: changed ? headSha : current.lastPublishedHeadSha,\n\t\t\t\treconciliationRequired: false,\n\t\t\t\treconciliationCycles: 0,\n\t\t\t\tpipeline: changed ? null : current.pipeline,\n\t\t\t});\n\t\t\tconst repo = ctx.repo.get(\"repo\");\n\t\t\trecordRepositoryPublication(\n\t\t\t\t{\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},\n\t\t\t\theadSha,\n\t\t\t);\n\t\t};\n\t\tconst result = (\n\t\t\toutcome:\n\t\t\t\t| \"awaiting\"\n\t\t\t\t| \"feedback_ready\"\n\t\t\t\t| \"completed\"\n\t\t\t\t| \"aborted\"\n\t\t\t\t| \"ci_ready\"\n\t\t\t\t| \"conflict_ready\"\n\t\t\t\t| \"operator_action\",\n\t\t) => ({\n\t\t\toutcome,\n\t\t\tparams: { nextState: patchRemote(ctx.state, current) },\n\t\t});\n\t\tif (current.stopped) return result(\"aborted\");\n\t\tif (current.pendingEvidence) {\n\t\t\tconst evidence = current.pendingEvidence;\n\t\t\tconst needsOperator = evidence.kind === \"failure\" && current.ciRecoveryCycles >= 3;\n\t\t\tcurrent = applyPublicationEvidence(ctx.params, current, evidence, !needsOperator);\n\t\t\tcurrent.pendingEvidence = null;\n\t\t\tif (evidence.kind === \"cancelled\") return result(\"aborted\");\n\t\t\tif (evidence.kind === \"failure\")\n\t\t\t\treturn result(needsOperator ? \"operator_action\" : \"ci_ready\");\n\t\t\tif (evidence.kind === \"conflict\") return result(\"conflict_ready\");\n\t\t}\n\t\tctx.reportProgress(deliveryProgress(current, adapter.label));\n\t\tconst reconcileAgain = () => {\n\t\t\tconst cycles = (current.reconciliationCycles ?? 0) + 1;\n\t\t\tupdate({\n\t\t\t\treconciliationRequired: true,\n\t\t\t\treconciliationCycles: cycles,\n\t\t\t\trepairPending: true,\n\t\t\t\tconflict: null,\n\t\t\t\tlastConflictKey: null,\n\t\t\t\tpipeline: null,\n\t\t\t\tdelivery: { adjustment: null, feedbackResult: null },\n\t\t\t});\n\t\t\treturn result(cycles > 3 ? \"operator_action\" : \"conflict_ready\");\n\t\t};\n\n\t\tif (current.delivery.terminalPullRequest) {\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"reconcile_terminal\"));\n\t\t\tconst pr = current.delivery.terminalPullRequest;\n\t\t\tawait adapter.reconcileTerminal(ctx, current, pr);\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label));\n\t\t\treturn result(pr.merged ? \"completed\" : \"aborted\");\n\t\t}\n\n\t\tif (\n\t\t\t!current.headSha &&\n\t\t\t(adapter.repositories || adapter.unchanged) &&\n\t\t\t!repositoryHasChanges(\n\t\t\t\tctx.repo.get(\"repo\").fsPath,\n\t\t\t\tctx.repo.get(\"repo\").baseBranch,\n\t\t\t\tctx.repo.get(\"repo\").key,\n\t\t\t)\n\t\t) {\n\t\t\tupdate({ noChanges: true });\n\t\t\tawait adapter.unchanged?.(ctx);\n\t\t\treturn result(\"completed\");\n\t\t}\n\t\tlet publicationLease = current.headSha;\n\t\tif (\n\t\t\t(!current.headSha || current.delivery.adjustment) &&\n\t\t\tcurrent.delivery.adjustment?.origin !== \"rebase\"\n\t\t) {\n\t\t\tconst synchronized = await reconcile(ctx, current);\n\t\t\tif (synchronized.status !== \"unchanged\") return reconcileAgain();\n\t\t\t// Fetch is authoritative even if the watcher has not observed a developer push yet.\n\t\t\tpublicationLease = synchronized.remoteHead;\n\t\t\tif (current.headSha && synchronized.remoteHead && current.headSha !== synchronized.remoteHead)\n\t\t\t\tupdate({ headSha: synchronized.remoteHead, workBaselineSha: synchronized.remoteHead });\n\t\t}\n\t\tif (!current.headSha) {\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"publish_branch\"));\n\t\t\tlet published: { headSha: string };\n\t\t\ttry {\n\t\t\t\tpublished = await commitWorkBranch(\n\t\t\t\t\tctx,\n\t\t\t\t\tctx.state.finalization.commitMessages?.[ctx.repo.get(\"repo\").key] ??\n\t\t\t\t\t\tctx.state.finalization.generatedCommitMessage ??\n\t\t\t\t\t\t\"\",\n\t\t\t\t\tpublicationLease,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof RemoteBranchChangedError)) throw error;\n\t\t\t\treturn reconcileAgain();\n\t\t\t}\n\t\t\tacknowledgePublication(published.headSha, true);\n\t\t}\n\n\t\tif (!current.prNumber || !current.prUrl) {\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"open_pr\"));\n\t\t\tconst pr = await adapter.ensureRequest(ctx);\n\t\t\tupdate({ prNumber: pr.number, prUrl: pr.html_url });\n\t\t}\n\n\t\tif (!current.delivery.issueLinked) {\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"link_issue\"));\n\t\t\tawait adapter.linkIssue(ctx, current);\n\t\t\tupdate({ delivery: { issueLinked: true } });\n\t\t}\n\n\t\tif (current.delivery.adjustment) {\n\t\t\tconst adjustment = current.delivery.adjustment;\n\t\t\tif (adjustment.origin === \"rebase\" && !hasPreparedRebase(rebaseInput(ctx)))\n\t\t\t\treturn reconcileAgain();\n\t\t\tlet adjustmentPublished = false;\n\t\t\tif (adjustment.publishRequired || adjustment.origin === \"rebase\" || adapter.maintenance) {\n\t\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"publish_adjustment\"));\n\t\t\t\tif (adapter.maintenance)\n\t\t\t\t\tawait ctx.callIntegrationTool(adapter.maintenance.ownershipTool, {\n\t\t\t\t\t\tprojectKey: ctx.repo.get(\"repo\").key,\n\t\t\t\t\t});\n\t\t\t\tlet published: { headSha: string };\n\t\t\t\ttry {\n\t\t\t\t\tpublished =\n\t\t\t\t\t\tadjustment.origin === \"rebase\"\n\t\t\t\t\t\t\t? publishRebase(rebaseInput(ctx))\n\t\t\t\t\t\t\t: await commitWorkBranch(\n\t\t\t\t\t\t\t\t\t{ ...ctx, state: patchRemote(ctx.state, current) },\n\t\t\t\t\t\t\t\t\tadapter.commitMessage(adjustment.origin),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof ConcurrentRebaseSourceError) {\n\t\t\t\t\t\tif (error.published) return reconcileAgain();\n\t\t\t\t\t\tconst project = ctx.repo.get(\"repo\");\n\t\t\t\t\t\tretainConcurrentRebase({\n\t\t\t\t\t\t\tprojectKey: project.key,\n\t\t\t\t\t\t\trepoPath: project.fsPath,\n\t\t\t\t\t\t\tworkBranch: project.workBranch,\n\t\t\t\t\t\t\tbaselineSha: error.repair.originalHead,\n\t\t\t\t\t\t\trebasedHead: error.repair.headSha,\n\t\t\t\t\t\t\ttargetBase: error.repair.baseSha,\n\t\t\t\t\t\t\tgitIdentity: await adapter.identity(ctx),\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn reconcileAgain();\n\t\t\t\t\t}\n\t\t\t\t\tif (!(error instanceof RemoteBranchChangedError)) throw error;\n\t\t\t\t\treturn reconcileAgain();\n\t\t\t\t}\n\t\t\t\tif (adjustment.origin === \"rebase\") {\n\t\t\t\t\tconst head = await adapter.head(ctx, current);\n\t\t\t\t\tif (head !== published.headSha)\n\t\t\t\t\t\tthrow new Error(\"Pull request head has not caught up with rebase publication\");\n\t\t\t\t}\n\t\t\t\tadjustmentPublished = published.headSha !== publicationLease;\n\t\t\t\tacknowledgePublication(published.headSha, adjustmentPublished);\n\t\t\t}\n\t\t\tif (adjustment.origin === \"rebase\") await adapter.afterRebase(ctx, current);\n\t\t\tif (adjustment.origin === \"feedback\" && !adapter.maintenance) {\n\t\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"reply_feedback\"));\n\t\t\t\tawait adapter.reply(ctx, current);\n\t\t\t}\n\t\t\tupdate({\n\t\t\t\t...(adjustment.origin === \"feedback\" && !adapter.maintenance ? { feedbackIds: [] } : {}),\n\t\t\t\t...(adjustment.origin === \"rebase\" ? { conflict: null } : {}),\n\t\t\t\tdelivery: {\n\t\t\t\t\tadjustment: null,\n\t\t\t\t\t...(adjustment.origin === \"feedback\" && adapter.maintenance\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tfeedbackResult: {\n\t\t\t\t\t\t\t\t\tpublished: adjustmentPublished,\n\t\t\t\t\t\t\t\t\tsummary: adjustmentPublished\n\t\t\t\t\t\t\t\t\t\t? \"Review adjustment published\"\n\t\t\t\t\t\t\t\t\t\t: (adjustment.summary ?? \"No repository change was required\"),\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},\n\t\t\t});\n\t\t}\n\n\t\tif (current.feedbackIds.length > 0 && !adapter.maintenance) {\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"reply_feedback\"));\n\t\t\tawait adapter.acknowledge(ctx, current);\n\t\t\treturn result(\"feedback_ready\");\n\t\t}\n\n\t\tupdate({ delivery: { stage: \"awaiting\" } });\n\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"await_evidence\"));\n\t\treturn result(\"awaiting\");\n\t};\n\tconst delivery = flow\n\t\t.automatic<P, RepositoryChangeState>(ids.deliver)\n\t\t.description(\"Deliver\")\n\t\t.waitFor(({ state, params }) => {\n\t\t\tconst states = adapter.repositories\n\t\t\t\t? adapter.repositories(params).map(({ key }) => select(state, key))\n\t\t\t\t: [state];\n\t\t\treturn states.some((state) => {\n\t\t\t\tconst current = remote(state);\n\t\t\t\tif (adapter.maintenance)\n\t\t\t\t\treturn (\n\t\t\t\t\t\t!current.stopped &&\n\t\t\t\t\t\t!current.noChanges &&\n\t\t\t\t\t\t!current.delivery.terminalPullRequest &&\n\t\t\t\t\t\t(current.delivery.stage !== \"awaiting\" || !!current.delivery.adjustment)\n\t\t\t\t\t);\n\t\t\t\treturn (\n\t\t\t\t\tcurrent.delivery.stage !== \"awaiting\" ||\n\t\t\t\t\t!!current.pendingEvidence ||\n\t\t\t\t\t!!current.delivery.adjustment ||\n\t\t\t\t\tcurrent.feedbackIds.length > 0 ||\n\t\t\t\t\t!!current.delivery.terminalPullRequest\n\t\t\t\t);\n\t\t\t});\n\t\t})\n\t\t.integrationTools(...adapter.tools.delivery)\n\t\t.run(async (ctx) => {\n\t\t\tif (!adapter.repositories) return runRepository(ctx);\n\t\t\tlet state = ctx.state;\n\t\t\tconst repositories = adapter.repositories(ctx.params);\n\t\t\tif (!repositories.length) throw new Error(\"No repositories are bound\");\n\t\t\tconst results = () =>\n\t\t\t\trepositories.map(({ key }) => ({ key, current: remote(select(state, key)) }));\n\t\t\tconst finished = () => results().every(({ current }) => publicationFinished(current));\n\t\t\t// Terminal facts take precedence over cancellation, including after interrupted publication.\n\t\t\tconst reconcileTerminals = async () => {\n\t\t\t\tfor (const { key } of repositories) {\n\t\t\t\t\tstate = select(state, key);\n\t\t\t\t\tconst current = remote(state);\n\t\t\t\t\tif (publicationFinished(current)) continue;\n\t\t\t\t\tconst terminal = await adapter.observeTerminal?.(\n\t\t\t\t\t\trepositoryContext({ ...ctx, state }),\n\t\t\t\t\t\tcurrent,\n\t\t\t\t\t);\n\t\t\t\t\tif (terminal)\n\t\t\t\t\t\tstate = patchRemote(state, {\n\t\t\t\t\t\t\tprNumber: terminal.number,\n\t\t\t\t\t\t\tprUrl: terminal.html_url,\n\t\t\t\t\t\t\tdelivery: { terminalPullRequest: terminal },\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\t\t\tawait reconcileTerminals();\n\t\t\tlet cancelled = false;\n\t\t\tfor (const { key } of repositories) {\n\t\t\t\tstate = select(state, key);\n\t\t\t\tif (publicationFinished(remote(state))) continue;\n\t\t\t\tif (await adapter.sourceCancelled?.({ ...ctx, state })) {\n\t\t\t\t\tawait reconcileTerminals();\n\t\t\t\t\tcancelled = !finished();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconst result = await runRepository(repositoryContext({ ...ctx, state }));\n\t\t\t\tstate = result.params.nextState;\n\t\t\t\tif (![\"awaiting\", \"completed\", \"aborted\"].includes(result.outcome))\n\t\t\t\t\treturn { ...result, params: { nextState: state } };\n\t\t\t}\n\t\t\tif (cancelled || finished()) {\n\t\t\t\tawait adapter.reconcileAll?.({ ...ctx, state }, results(), cancelled);\n\t\t\t\tconst requests = results().flatMap(({ current }) =>\n\t\t\t\t\tcurrent.delivery.terminalPullRequest ? [current.delivery.terminalPullRequest] : [],\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\toutcome:\n\t\t\t\t\t\tcancelled || (requests.length > 0 && requests.every((request) => !request.merged))\n\t\t\t\t\t\t\t? \"aborted\"\n\t\t\t\t\t\t\t: \"completed\",\n\t\t\t\t\tparams: { nextState: state },\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn { outcome: \"awaiting\", params: { nextState: state } };\n\t\t});\n\tconst outcome = (o: AutomaticOutcomeBuilder<P, RepositoryChangeState>, description: string) =>\n\t\to\n\t\t\t.description(description)\n\t\t\t.object(\"nextState\")\n\t\t\t.state(({ event }) => event.params.nextState as RepositoryChangeState);\n\tdelivery\n\t\t.outcome(\"awaiting\", (o) => outcome(o, \"Delivery is waiting for external evidence\").wait())\n\t\t.outcome(\"completed\", (o) => outcome(o, \"Merged pull request was reconciled\").complete())\n\t\t.outcome(\"aborted\", (o) =>\n\t\t\toutcome(o, \"Closed pull request was reconciled\").lifecycleStatus(\"aborted\"),\n\t\t);\n\tif (!adapter.maintenance)\n\t\tdelivery.outcome(\"feedback_ready\", (o) =>\n\t\t\toutcome(o, \"Pull request feedback is acknowledged and ready for revision\").to(ids.feedback),\n\t\t);\n\tfor (const [name, target] of [\n\t\t[\"ci_ready\", ids.ciRepair],\n\t\t[\"conflict_ready\", ids.feedback],\n\t\t[\"operator_action\", ids.operator],\n\t] as const) {\n\t\tdelivery.outcome(name, (o) => outcome(o, \"Route observed delivery evidence\").to(target));\n\t}\n\tfor (const source of adapter.sources) {\n\t\tif (adapter.maintenance && source.kind === \"observation\") continue;\n\t\tconst attach = (id: string, operator: boolean) =>\n\t\t\tdelivery.externalAction(id, source.source, (external) => {\n\t\t\t\texternal\n\t\t\t\t\t.label(source.label)\n\t\t\t\t\t.when(\n\t\t\t\t\t\t({ params, state }) =>\n\t\t\t\t\t\t\t(!source.enabled || source.enabled(params, state)) &&\n\t\t\t\t\t\t\t(source.kind === \"cancelled\" ||\n\t\t\t\t\t\t\t\t(adapter.repositories\n\t\t\t\t\t\t\t\t\t? adapter.repositories(params).map(({ key }) => remote(select(state, key)))\n\t\t\t\t\t\t\t\t\t: [remote(state)]\n\t\t\t\t\t\t\t\t).every(\n\t\t\t\t\t\t\t\t\t(current) =>\n\t\t\t\t\t\t\t\t\t\tcurrent.noChanges ||\n\t\t\t\t\t\t\t\t\t\tcurrent.delivery.terminalPullRequest ||\n\t\t\t\t\t\t\t\t\t\t!!(current.headSha && current.prNumber && current.prUrl),\n\t\t\t\t\t\t\t\t)) &&\n\t\t\t\t\t\t\t(source.kind !== \"failure\" || remote(state).ciRecoveryCycles >= 3 === operator),\n\t\t\t\t\t);\n\t\t\t\tif (source.kind === \"cancelled\") return external.lifecycleStatus(\"aborted\");\n\t\t\t\texternal.to(\n\t\t\t\t\tsource.kind === \"conflict\"\n\t\t\t\t\t\t? ids.feedback\n\t\t\t\t\t\t: source.kind === \"failure\"\n\t\t\t\t\t\t\t? operator\n\t\t\t\t\t\t\t\t? ids.operator\n\t\t\t\t\t\t\t\t: ids.ciRepair\n\t\t\t\t\t\t\t: ids.deliver,\n\t\t\t\t);\n\t\t\t\treturn external.effect((input) => {\n\t\t\t\t\tconst evidence = source.read(input);\n\t\t\t\t\tconst state =\n\t\t\t\t\t\tadapter.repositories && evidence.projectKey\n\t\t\t\t\t\t\t? select(input.state, evidence.projectKey)\n\t\t\t\t\t\t\t: input.state;\n\t\t\t\t\tconst current = remote(state);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstate: patchRemote(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tsource.kind === \"observation\"\n\t\t\t\t\t\t\t\t? { pendingEvidence: evidence }\n\t\t\t\t\t\t\t\t: applyPublicationEvidence(input.params, current, evidence, !operator),\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t});\n\t\tattach(source.id, false);\n\t\tif (source.kind === \"failure\") attach(source.operatorId ?? `${source.id}_operator`, true);\n\t}\n\tif (adapter.maintenance) {\n\t\tfor (const [id, target] of [\n\t\t\t[\"feedback\", ids.feedback],\n\t\t\t[\"conflict\", ids.feedback],\n\t\t\t[\"ci\", ids.ciRepair],\n\t\t\t[\"operator\", ids.operator],\n\t\t] as const)\n\t\t\tdelivery.externalAction(`maintenance_${id}`, adapter.maintenance.source, (action) =>\n\t\t\t\taction\n\t\t\t\t\t.label(\"Maintain MR\")\n\t\t\t\t\t.to(target)\n\t\t\t\t\t.effect(({ event }) => ({ state: event.state })),\n\t\t\t);\n\t}\n\tpublication.turn(delivery);\n\tfunction rebaseInput(ctx: {\n\t\tstate: RepositoryChangeState;\n\t\trepo: { get(key: string): { fsPath: string; workBranch: string } };\n\t}) {\n\t\tconst project = ctx.repo.get(activeKey(ctx.state) ?? \"repo\");\n\t\tconst conflict = remote(ctx.state).conflict;\n\t\tif (!conflict) throw new Error(\"Missing conflict evidence\");\n\t\treturn {\n\t\t\tprojectKey: activeKey(ctx.state) ?? \"repo\",\n\t\t\tpath: project.fsPath,\n\t\t\tworkBranch: project.workBranch,\n\t\t\tconflict,\n\t\t};\n\t}\n\tfunction repairReason(state: RepositoryChangeState, kind: \"feedback\" | \"ci\") {\n\t\treturn kind === \"feedback\" && remote(state).repairReason === \"rebase\" ? \"rebase\" : kind;\n\t}\n\n\tfunction revisionPrompt(kind: \"feedback\" | \"ci\") {\n\t\treturn (ctx: {\n\t\t\tstate: RepositoryChangeState;\n\t\t\tprepared?: unknown;\n\t\t\tprompts?: { initial: string };\n\t\t}) => {\n\t\t\tconst current = remote(ctx.state);\n\t\t\tconst repository = adapter.repositories\n\t\t\t\t? `Repository: ${activeKey(ctx.state)}. Apply changes only to this checkout. `\n\t\t\t\t: \"\";\n\t\t\tif (asUnknownRecord(ctx.prepared)?.deferredRebase)\n\t\t\t\treturn `${repository}${reconciliationPrompt}\\nThe source branch or retained local work must be reconciled before the target-branch repair. Resolve any source reconciliation, then use changes_ready. Delivery will restore and validate the result before reassessing current target conflicts.`;\n\t\t\tif (current.reconciliationRequired)\n\t\t\t\treturn `${repository}${reconciliationPrompt}\\nValidate the reconciled repository, including any upstream target changes and retained local work, against the requested change and pending feedback: ${JSON.stringify(current.feedbackIds)}. Treat the current remote as authoritative; do not restore deliberately removed code simply to match an older plan. Use changes_ready after validation, even when no further edit is needed, so retained local changes are published. If blocked use cannot_repair.\\nOriginal request for context: ${ctx.prompts?.initial ?? \"Inspect the current repository and retained request\"}`;\n\t\t\tif (repairReason(ctx.state, kind) === \"rebase\")\n\t\t\t\treturn `${rebasePrompt} Evidence: ${JSON.stringify(current.conflict)}. Call changes_ready or no_changes when verified complete, cannot_repair when blocked.`;\n\t\t\treturn `${adapter.repositories ? `Repository: ${activeKey(ctx.state)}. Apply changes only to this checkout. ` : \"\"}${adapter.prompt(kind, current)}\\n\\n${reconciliationPrompt}`;\n\t\t};\n\t}\n\n\tfunction revisionTurn(id: string, kind: \"feedback\" | \"ci\") {\n\t\tconst turn = flow\n\t\t\t.llm<P, RepositoryChangeState>(id)\n\t\t\t.description(kind === \"feedback\" ? \"Address Feedback\" : \"Fix CI\")\n\t\t\t.waitFor(({ state }) => {\n\t\t\t\tconst current = remote(state);\n\t\t\t\treturn (\n\t\t\t\t\t!current.stopped &&\n\t\t\t\t\t!current.delivery.terminalPullRequest &&\n\t\t\t\t\t(kind === \"feedback\"\n\t\t\t\t\t\t? current.feedbackIds.length > 0 ||\n\t\t\t\t\t\t\t!!current.conflict ||\n\t\t\t\t\t\t\t!!current.reconciliationRequired\n\t\t\t\t\t\t: current.repairReason === \"ci\" && current.pipeline !== null)\n\t\t\t\t);\n\t\t\t})\n\t\t\t.executionPurpose(codingPurposes.implementation)\n\t\t\t.tools(\"read\", \"bash\", \"edit\", \"write\")\n\t\t\t.resolveIntegrationTools((_params, state) =>\n\t\t\t\trepairReason(state, kind) === \"rebase\" && !remote(state).reconciliationRequired\n\t\t\t\t\t? []\n\t\t\t\t\t: adapter.tools[kind],\n\t\t\t)\n\t\t\t.prepare(async (ctx) => {\n\t\t\t\tconst project = ctx.repo.get(activeKey(ctx.state) ?? \"repo\");\n\t\t\t\tconst current = remote(ctx.state);\n\t\t\t\tconst targetRebase =\n\t\t\t\t\trepairReason(ctx.state, kind) === \"rebase\" && !current.reconciliationRequired;\n\t\t\t\t// Resume Git's existing target repair; it must not be mistaken for source synchronization.\n\t\t\t\tif (targetRebase && hasPreparedRebase(rebaseInput(ctx)))\n\t\t\t\t\treturn { rebase: startRebase(rebaseInput(ctx)) };\n\t\t\t\tconst report = (label: string, status: \"in_progress\" | \"completed\") =>\n\t\t\t\t\tctx.reportProgress({\n\t\t\t\t\t\ttitle: \"Repository reconciliation\",\n\t\t\t\t\t\tsteps: [{ id: \"reconcile_source\", label, status }],\n\t\t\t\t\t});\n\t\t\t\treport(\"Reconcile remote changes and retained local work\", \"in_progress\");\n\t\t\t\tconst reconciliation = await reconcile(repositoryContext(ctx), current);\n\t\t\t\tif (reconciliation.status === \"conflicts\")\n\t\t\t\t\treport(\"Resolve reconciliation conflicts\", \"in_progress\");\n\t\t\t\telse report(\"Repository reconciled\", \"completed\");\n\t\t\t\tif (targetRebase) {\n\t\t\t\t\tif (\n\t\t\t\t\t\treconciliation.status !== \"unchanged\" ||\n\t\t\t\t\t\treconciliation.headSha !== current.conflict?.headSha ||\n\t\t\t\t\t\trepositoryWorktreeIsDirty({ projectKey: project.key, repoPath: project.fsPath })\n\t\t\t\t\t)\n\t\t\t\t\t\treturn { reconciliation, deferredRebase: true };\n\t\t\t\t\treturn { rebase: startRebase(rebaseInput(ctx)) };\n\t\t\t\t}\n\t\t\t\treturn { reconciliation };\n\t\t\t})\n\t\t\t.freshPrimary()\n\t\t\t.prompt(revisionPrompt(kind));\n\t\tfor (const [name, description] of [\n\t\t\t[\"changes_ready\", \"Repository changes are ready to publish\"],\n\t\t\t[\"no_changes\", \"No repository change is required\"],\n\t\t] as const) {\n\t\t\tturn.outcomeTool(name, (tool) =>\n\t\t\t\ttool\n\t\t\t\t\t.resultSummary()\n\t\t\t\t\t.description(description)\n\t\t\t\t\t.to(ids.deliver)\n\t\t\t\t\t.state(({ ctx, event }) =>\n\t\t\t\t\t\tpatchRemote(ctx.state, {\n\t\t\t\t\t\t\trepairPending: false,\n\t\t\t\t\t\t\tdelivery: {\n\t\t\t\t\t\t\t\t// Even no_changes must cross delivery's remote race check. It may\n\t\t\t\t\t\t\t\t// have inherited unpublished work or a concurrent developer push.\n\t\t\t\t\t\t\t\tadjustment: {\n\t\t\t\t\t\t\t\t\torigin: remote(ctx.state).reconciliationRequired\n\t\t\t\t\t\t\t\t\t\t? \"feedback\"\n\t\t\t\t\t\t\t\t\t\t: repairReason(ctx.state, kind),\n\t\t\t\t\t\t\t\t\tpublishRequired:\n\t\t\t\t\t\t\t\t\t\tname === \"changes_ready\" || !!remote(ctx.state).reconciliationRequired,\n\t\t\t\t\t\t\t\t\tsummary: String(\n\t\t\t\t\t\t\t\t\t\tevent.params?.resultSummary ?? \"No repository change was required\",\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}),\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn turn.outcomeTool(\"cannot_repair\", (tool) => {\n\t\t\tconst outcome = tool.description(\"The adjustment requires operator action\").to(ids.operator);\n\t\t\treturn adapter.maintenance\n\t\t\t\t? outcome.state(({ ctx }) => patchRemote(ctx.state, { repairPending: false }))\n\t\t\t\t: outcome;\n\t\t});\n\t}\n\n\tpublication.turn(revisionTurn(ids.feedback, \"feedback\"));\n\tpublication.turn(revisionTurn(ids.ciRepair, \"ci\"));\n\tconst maintenanceSource = adapter.maintenance?.source;\n\tpublication.turn({\n\t\tid: ids.operator,\n\t\tdefinition: {\n\t\t\tkind: \"human\",\n\t\t\tdescription: \"Repository repair needs operator action\",\n\t\t\toperatorAttention: \"required\",\n\t\t\t...(maintenanceSource\n\t\t\t\t? {\n\t\t\t\t\t\texternalActions: Object.fromEntries(\n\t\t\t\t\t\t\t([\"feedback\", \"conflict\"] as const).map((id) => [\n\t\t\t\t\t\t\t\t`maintenance_${id}`,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: `maintenance_${id}`,\n\t\t\t\t\t\t\t\t\tsource: maintenanceSource,\n\t\t\t\t\t\t\t\t\tto: ids.feedback,\n\t\t\t\t\t\t\t\t\tlabel: \"Maintain MR\",\n\t\t\t\t\t\t\t\t\teffect: ({ event }: { event: unknown }) => ({\n\t\t\t\t\t\t\t\t\t\tstate: (event as { state: RepositoryChangeState }).state,\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),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\tactions: {\n\t\t\t\tretry_repair: {\n\t\t\t\t\tlabel: \"Retry repair\",\n\t\t\t\t\tacceptanceState: \"accepted\",\n\t\t\t\t\tbranches: { feedback: { to: ids.feedback }, ci: { to: ids.ciRepair } },\n\t\t\t\t\teffect: adapter.maintenance\n\t\t\t\t\t\t? ({ ctx }) => ({ state: patchRemote(ctx.state, { reconciliationCycles: 0 }) })\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tchoose: ({ ctx }) =>\n\t\t\t\t\t\tremote(ctx.state).repairReason === \"rebase\" ||\n\t\t\t\t\t\tremote(ctx.state).repairReason === \"feedback\" ||\n\t\t\t\t\t\tremote(ctx.state).reconciliationRequired\n\t\t\t\t\t\t\t? \"feedback\"\n\t\t\t\t\t\t\t: \"ci\",\n\t\t\t\t},\n\t\t\t\tresume_waiting: {\n\t\t\t\t\tlabel: \"Resume waiting\",\n\t\t\t\t\tacceptanceState: \"accepted\",\n\t\t\t\t\tto: ids.deliver,\n\t\t\t\t\teffect: ({ ctx }) => ({\n\t\t\t\t\t\tstate: patchRemote(ctx.state, {\n\t\t\t\t\t\t\trepairPending: false,\n\t\t\t\t\t\t\tfeedbackIds: [],\n\t\t\t\t\t\t\tdelivery: { adjustment: null },\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\tabort: { label: \"Abort process\", acceptanceState: \"neutral\", lifecycleStatus: \"aborted\" },\n\t\t\t},\n\t\t},\n\t});\n\n\treturn {\n\t\t/** @public */\n\t\tentryTurnId: ids.deliver,\n\n\t\t/** @public */\n\t\tfragment: publication,\n\n\t\t/** @public */\n\t\thappyPath: [ids.deliver],\n\t};\n}\n","import { execFileSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { repositoryGitArgs, repositoryGitSubprocessEnv } from \"@leitwerk-dev/process-sdk\";\nimport { resolveGitBinary } from \"@leitwerk-dev/process-sdk/git-binary\";\nimport {\n\tpushWasRejected,\n\ttype RepositoryPublicationReceipt,\n\treadPublicationReceipt,\n\treadRepositoryBinding,\n\trepositoryBindingMatches,\n\tsavePublicationReceipt,\n} from \"../repository-publication-receipt.js\";\nimport { assertReconciliationTargetSafe } from \"../repository-reconciliation.js\";\nimport { repositoryRecord } from \"../repository-record.js\";\n\nimport { type ConflictEvidence, conflictKey } from \"./index.js\";\nimport {\n\ttype RebaseRecord,\n\trequireRebaseHead,\n\trequireRebaseOrigin,\n\trequireRebaseTarget,\n\trequireRebaseWorktree,\n} from \"./policy.js\";\n\n/** @internal */\nexport interface RebaseInput {\n\t/** @internal */\n\tprojectKey: string;\n\t/** @internal */\n\tpath: string;\n\t/** @internal */\n\tworkBranch: string;\n\t/** @internal */\n\tconflict: ConflictEvidence;\n}\nfunction git(input: RebaseInput, ...args: string[]): string {\n\treturn execFileSync(resolveGitBinary(), repositoryGitArgs(args), {\n\t\tcwd: input.path,\n\t\tencoding: \"utf8\",\n\t\tenv: repositoryGitSubprocessEnv(input.projectKey, {\n\t\t\tGIT_TERMINAL_PROMPT: \"0\",\n\t\t\tGIT_EDITOR: \"true\",\n\t\t}),\n\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t}).trim();\n}\nfunction area(input: RebaseInput): string {\n\treturn git(input, \"rev-parse\", \"--absolute-git-dir\");\n}\nfunction active(gitDir: string): boolean {\n\treturn [\"rebase-merge\", \"rebase-apply\"].some((name) => existsSync(join(gitDir, name)));\n}\nconst recordFile = (gitDir: string) => repositoryRecord<RebaseRecord>(gitDir, \"rebase\");\nfunction requireWorktree(input: RebaseInput): void {\n\trequireRebaseWorktree(input.workBranch, {\n\t\tbranch: git(input, \"branch\", \"--show-current\"),\n\t\tdirty: Boolean(git(input, \"status\", \"--porcelain\")),\n\t});\n}\nfunction remoteHead(input: RebaseInput): string {\n\treturn git(input, \"ls-remote\", \"--heads\", \"origin\", `refs/heads/${input.workBranch}`).split(\n\t\t/\\s+/,\n\t)[0];\n}\n\nfunction requireTarget(input: RebaseInput, record?: RebaseRecord | null): void {\n\trequireRebaseTarget(input.workBranch, input.conflict, record);\n\tgit(input, \"check-ref-format\", `refs/heads/${input.workBranch}`);\n\tgit(input, \"check-ref-format\", `refs/heads/${input.conflict.baseBranch}`);\n\trequireRebaseOrigin(record, {\n\t\toriginUrl: record?.originUrl ? git(input, \"remote\", \"get-url\", \"origin\") : undefined,\n\t\toriginPushUrl: record?.originPushUrl\n\t\t\t? git(input, \"remote\", \"get-url\", \"--push\", \"--all\", \"origin\")\n\t\t\t: undefined,\n\t});\n}\n\nfunction verifyCurrentBase(input: RebaseInput, record: RebaseRecord): void {\n\tgit(\n\t\tinput,\n\t\t\"fetch\",\n\t\t\"origin\",\n\t\t`+refs/heads/${input.conflict.baseBranch}:refs/leitwerk/rebase-base`,\n\t);\n\t// A fast-forward is compatible with captured preparation; a rewritten base is not.\n\tgit(input, \"merge-base\", \"--is-ancestor\", record.baseSha, \"refs/leitwerk/rebase-base\");\n}\n\nfunction verifyNoRepairNeeded(input: RebaseInput, headSha: string, baseSha: string): void {\n\tif (input.conflict.reason === \"behind\")\n\t\tgit(input, \"merge-base\", \"--is-ancestor\", baseSha, headSha);\n\telse git(input, \"merge-tree\", \"--write-tree\", headSha, baseSha);\n}\n\n/** @internal */\nexport function hasPreparedRebase(input: RebaseInput): boolean {\n\treturn recordFile(area(input)).read()?.key === conflictKey(input.conflict);\n}\n\n/** Persist the lease before changing HEAD; a retry resumes Git's own rebase state. @internal */\nexport function prepareRebase(input: RebaseInput): RebaseRecord {\n\tconst gitDir = area(input);\n\tconst old = recordFile(gitDir).read();\n\trequireTarget(input, old?.key === conflictKey(input.conflict) ? old : null);\n\tif (old?.key === conflictKey(input.conflict)) {\n\t\tverifyCurrentBase(input, old);\n\t\treturn old;\n\t}\n\tif (active(gitDir)) throw new Error(\"An unrelated rebase is already in progress\");\n\trequireWorktree(input);\n\tgit(\n\t\tinput,\n\t\t\"fetch\",\n\t\t\"origin\",\n\t\t`+refs/heads/${input.workBranch}:refs/leitwerk/rebase-head`,\n\t\t`+refs/heads/${input.conflict.baseBranch}:refs/leitwerk/rebase-base`,\n\t);\n\tconst [remoteSha, headSha, baseSha] = git(\n\t\tinput,\n\t\t\"rev-parse\",\n\t\t\"refs/leitwerk/rebase-head\",\n\t\t\"HEAD\",\n\t\t\"refs/leitwerk/rebase-base\",\n\t).split(\"\\n\");\n\trequireRebaseHead(input.conflict.headSha, headSha, remoteSha);\n\t// Use the current fetched base, retaining the provider pair for deduplication.\n\tgit(input, \"merge-base\", \"--is-ancestor\", input.conflict.baseSha, baseSha);\n\tconst record: RebaseRecord = {\n\t\tkey: conflictKey(input.conflict),\n\t\tbranch: input.workBranch,\n\t\toriginalHead: input.conflict.headSha,\n\t\tbaseSha,\n\t\tstatus: \"prepared\",\n\t\toriginUrl: git(input, \"remote\", \"get-url\", \"origin\"),\n\t\toriginPushUrl: git(input, \"remote\", \"get-url\", \"--push\", \"--all\", \"origin\"),\n\t\tbaseBranch: input.conflict.baseBranch,\n\t};\n\tgit(input, \"update-ref\", \"refs/leitwerk/rebase-original\", record.originalHead);\n\trecordFile(gitDir).save(record);\n\treturn record;\n}\n/** @internal */\nexport function startRebase(input: RebaseInput): RebaseRecord {\n\tconst record = prepareRebase(input);\n\tconst gitDir = area(input);\n\tif (active(gitDir)) return record;\n\tif (record.status === \"clean\") return record;\n\trequireWorktree(input);\n\tif (record.status === \"rebasing\" && git(input, \"rev-parse\", \"HEAD\") !== record.originalHead)\n\t\treturn record;\n\ttry {\n\t\tverifyNoRepairNeeded(input, record.originalHead, record.baseSha);\n\t\trecord.status = \"clean\";\n\t\trecordFile(gitDir).save(record);\n\t\treturn record;\n\t} catch (error) {\n\t\tif ((error as { status?: number }).status !== 1) throw error;\n\t}\n\tassertReconciliationTargetSafe(\n\t\t{ projectKey: input.projectKey, repoPath: input.path },\n\t\trecord.baseSha,\n\t);\n\trecord.status = \"rebasing\";\n\trecordFile(gitDir).save(record);\n\ttry {\n\t\tgit(input, \"rebase\", \"--rebase-merges\", record.baseSha);\n\t} catch (error) {\n\t\tif (!active(gitDir)) throw error;\n\t}\n\treturn record;\n}\n/** @internal */\nexport function verifyRebase(input: RebaseInput): {\n\t/** @internal */\n\theadSha: string;\n\t/** @internal */\n\tchanged: boolean;\n\t/** @internal */\n\toriginalHead: string;\n\t/** @internal */\n\tbaseSha: string;\n} {\n\tconst gitDir = area(input);\n\tconst record = recordFile(gitDir).read();\n\tif (!record || record.key !== conflictKey(input.conflict))\n\t\tthrow new Error(\"Missing matching rebase metadata\");\n\trequireTarget(input, record);\n\tif (active(gitDir)) throw new Error(\"Rebase is incomplete\");\n\trequireWorktree(input);\n\tconst headSha = git(input, \"rev-parse\", \"HEAD\");\n\tif (record.status === \"clean\") {\n\t\tif (headSha !== record.originalHead)\n\t\t\tthrow new Error(\"Clean conflict report must not rewrite the branch\");\n\t\tverifyNoRepairNeeded(input, headSha, record.baseSha);\n\t} else {\n\t\tif (record.status !== \"rebasing\") throw new Error(\"Rebase was not started\");\n\t\tgit(input, \"merge-base\", \"--is-ancestor\", record.baseSha, headSha);\n\t}\n\treturn {\n\t\theadSha,\n\t\tchanged: headSha !== record.originalHead,\n\t\toriginalHead: record.originalHead,\n\t\tbaseSha: record.baseSha,\n\t};\n}\n/** @internal */\nexport class ConcurrentRebaseSourceError extends Error {\n\tconstructor(\n\t\treadonly repair: ReturnType<typeof verifyRebase>,\n\t\treadonly published = false,\n\t) {\n\t\tsuper(\"Concurrent remote change rejected by rebase lease; local repair was retained\");\n\t}\n}\n\n/** @internal */\nexport function publishRebase(input: RebaseInput): ReturnType<typeof verifyRebase> {\n\tconst result = verifyRebase(input);\n\tassertReconciliationTargetSafe(\n\t\t{ projectKey: input.projectKey, repoPath: input.path },\n\t\tresult.baseSha,\n\t);\n\tconst gitDir = area(input);\n\tconst record = recordFile(gitDir).read();\n\tif (!record) throw new Error(\"Missing matching rebase metadata\");\n\tverifyCurrentBase(input, record);\n\tconst remote = remoteHead(input);\n\tconst binding = readRepositoryBinding((...args) => git(input, ...args), input.workBranch);\n\tif (binding.origin !== binding.pushOrigin)\n\t\tthrow new Error(\"Fetch and push endpoints must match for publication\");\n\tconst previous = readPublicationReceipt(gitDir);\n\tif (!repositoryBindingMatches(previous, binding))\n\t\tthrow new Error(\"Repository publication receipt binding changed\");\n\tconst receipt: RepositoryPublicationReceipt = {\n\t\t...binding,\n\t\texpectedHead: result.originalHead,\n\t\tcandidate: result.headSha,\n\t\tstatus: \"attempting\",\n\t};\n\tif (remote === result.headSha) {\n\t\tsavePublicationReceipt(gitDir, { ...receipt, status: \"accepted\" });\n\t\treturn result;\n\t}\n\tif (previous?.candidate === result.headSha && previous.status === \"accepted\")\n\t\tthrow new ConcurrentRebaseSourceError(result, true);\n\tif (previous?.status === \"attempting\") {\n\t\tgit(\n\t\t\tinput,\n\t\t\t\"fetch\",\n\t\t\t\"--no-tags\",\n\t\t\t\"origin\",\n\t\t\t`+refs/heads/${input.workBranch}:refs/leitwerk/rebase-publication-proof`,\n\t\t);\n\t\ttry {\n\t\t\tgit(\n\t\t\t\tinput,\n\t\t\t\t\"merge-base\",\n\t\t\t\t\"--is-ancestor\",\n\t\t\t\tprevious.candidate,\n\t\t\t\t\"refs/leitwerk/rebase-publication-proof\",\n\t\t\t);\n\t\t} catch {\n\t\t\tthrow new Error(\n\t\t\t\t\"Prior target publication outcome is uncertain; local repair was retained for operator reconciliation\",\n\t\t\t);\n\t\t}\n\t\tsavePublicationReceipt(gitDir, { ...previous, status: \"accepted\" });\n\t\tthrow new ConcurrentRebaseSourceError(result, previous.candidate === result.headSha);\n\t}\n\tif (remote !== result.originalHead) throw new ConcurrentRebaseSourceError(result);\n\tsavePublicationReceipt(gitDir, receipt);\n\ttry {\n\t\tgit(\n\t\t\tinput,\n\t\t\t\"push\",\n\t\t\t\"--porcelain\",\n\t\t\t\"--no-follow-tags\",\n\t\t\t\"--recurse-submodules=no\",\n\t\t\t`--force-with-lease=refs/heads/${input.workBranch}:${result.originalHead}`,\n\t\t\t\"origin\",\n\t\t\t`${result.headSha}:refs/heads/${input.workBranch}`,\n\t\t);\n\t} catch (error) {\n\t\tconst rejected = pushWasRejected((error as { stdout?: Buffer }).stdout?.toString() ?? \"\");\n\t\tif (rejected) savePublicationReceipt(gitDir, { ...receipt, status: \"rejected\" });\n\t\tconst latest = remoteHead(input);\n\t\tif (latest === result.headSha) {\n\t\t\tsavePublicationReceipt(gitDir, { ...receipt, status: \"accepted\" });\n\t\t\treturn result;\n\t\t}\n\t\tif (rejected && latest !== result.originalHead) throw new ConcurrentRebaseSourceError(result);\n\t\tthrow error;\n\t}\n\tsavePublicationReceipt(gitDir, { ...receipt, status: \"accepted\" });\n\tif (remoteHead(input) !== result.headSha) throw new ConcurrentRebaseSourceError(result, true);\n\treturn result;\n}\n","import type { ConflictEvidence } from \"./index.js\";\n\n/** Durable preparation evidence; optional identity fields support older records. @internal */\nexport interface RebaseRecord {\n\t/** @internal */\n\tkey: string;\n\t/** @internal */\n\tbranch: string;\n\t/** @internal */\n\toriginalHead: string;\n\t/** @internal */\n\tbaseSha: string;\n\t/** @internal */\n\tstatus: \"prepared\" | \"rebasing\" | \"clean\";\n\t/** @internal */\n\toriginUrl?: string;\n\t/** @internal */\n\toriginPushUrl?: string;\n\t/** @internal */\n\tbaseBranch?: string;\n}\n\n/** Validate provider evidence against the tracked branch and retained preparation. @internal */\nexport function requireRebaseTarget(\n\tworkBranch: string,\n\tconflict: ConflictEvidence,\n\trecord?: RebaseRecord | null,\n): void {\n\tif (workBranch !== conflict.headBranch || workBranch === conflict.baseBranch)\n\t\tthrow new Error(\"Expected evidence for the tracked work branch and a distinct base\");\n\tif (record && (record.branch !== workBranch || record.originalHead !== conflict.headSha))\n\t\tthrow new Error(\"Missing matching rebase metadata\");\n\tif (record?.baseBranch && record.baseBranch !== conflict.baseBranch)\n\t\tthrow new Error(\"Rebase base branch changed since preparation\");\n}\n\n/** Compare observed remote identity only where preparation retained it. @internal */\nexport function requireRebaseOrigin(\n\trecord: RebaseRecord | null | undefined,\n\torigin: { originUrl?: string; originPushUrl?: string },\n): void {\n\tif (\n\t\t(record?.originUrl && origin.originUrl !== record.originUrl) ||\n\t\t(record?.originPushUrl && origin.originPushUrl !== record.originPushUrl)\n\t)\n\t\tthrow new Error(\"Rebase origin changed since preparation\");\n}\n\n/** A repair may operate only on the clean tracked checkout. @internal */\nexport function requireRebaseWorktree(\n\tworkBranch: string,\n\tobservation: { branch: string; dirty: boolean },\n): void {\n\tif (observation.branch !== workBranch) throw new Error(\"Expected tracked work branch for rebase\");\n\tif (observation.dirty)\n\t\tthrow new Error(\"Rebase requires a clean worktree with no unresolved conflicts\");\n}\n\n/** Both local and remote heads must still match the provider's evidence. @internal */\nexport function requireRebaseHead(expected: string, local: string, remote: string): void {\n\tif (remote !== expected || local !== expected)\n\t\tthrow new Error(\"Tracked branch changed before repair\");\n}\n\n/** Recognize a completed write without accepting somebody else's remote update. @internal */\nexport function rebasePublicationDecision(\n\toriginalHead: string,\n\theadSha: string,\n\tremoteHead: string,\n): \"already_published\" | \"push\" {\n\tif (remoteHead === headSha) return \"already_published\";\n\tif (remoteHead !== originalHead)\n\t\tthrow new Error(\"Concurrent remote change rejected by rebase lease\");\n\treturn \"push\";\n}\n","/** @internal */\nexport const rebasePrompt = `Repair only the recorded pull request merge conflict or behind-base condition. Deterministic preparation has fetched and verified the tracked head and current base, retained the original head and lease in .git/leitwerk-rebase.json, and started the rebase if the conflict or missing base commits are confirmed locally. Inspect that metadata and git status first. For behind-base evidence, incorporate the fetched base even when merging would be clean. A clean preparation result means no rewrite is needed. Resolve conflicts preserving the requested behavior, original authors, and existing Signed-off-by trailers. You may use git add and GIT_EDITOR=true git rebase --continue until finished. This explicitly overrides the prohibition on creating commits only for rebase continuation. Do not create unrelated commits, reset the branch, skip commits, abort the rebase, or push. Run focused repository checks after resolution. Delivery verifies the completed rebase and publishes with the recorded pre-repair lease. If blocked, retain the workspace and explain the failure for retry or abort. Record a concise repair result.`;\n","import type {\n\tdefineExternalActionSource,\n\tProcessWatcherDefinition,\n\tRepositoryFeedbackSourceConfig,\n\tRepositoryIssueCancelledSourceConfig,\n\tRepositoryPullRequestSourceConfig,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { GitIdentity } from \"./finalization-git.js\";\nimport type { RepositoryIssueOriginParams } from \"./repository-change-launch-internal.js\";\nimport {\n\tcreateRepositoryChangeProcess,\n\ttype RepositoryChangeProcessConfig,\n} from \"./repository-change-process.js\";\nimport type {\n\tPublicationContext,\n\tPublicationEvidence,\n\tPublicationParams,\n\tPublicationRequest,\n\tPublicationSource,\n\tPublicationState,\n\tPublicationReconciliationContext as RemoteContext,\n\tRepositoryChangePublicationAdapter,\n} from \"./repository-change-publication.js\";\nimport {\n\tcreateRepositoryChangePublication,\n\tpublicationObject as object,\n\treadPublicationState,\n} from \"./repository-change-publication.js\";\nimport type { RepositoryChangeState } from \"./repository-change-state.js\";\n\n/** Shared process defaults for SSH-backed pull-request publication. @internal */\nexport function createPullRequestChangeProcess<\n\tP extends PublicationParams & {\n\t\t/** @internal */\n\t\tsshCredentialRef: string;\n\t},\n\tE,\n\tC,\n>(\n\tprovider: string,\n\tlabel: string,\n\tdocker: boolean,\n\tconfig: Pick<RepositoryChangeProcessConfig<P>, \"paramsCodec\" | \"launcher\" | \"workflow\"> & {\n\t\t/** @internal */ publication: RepositoryChangePublicationAdapter<P>;\n\t\t/** @internal */ watcher: Omit<\n\t\t\tProcessWatcherDefinition<P, E, C>,\n\t\t\t\"id\" | \"label\" | \"description\"\n\t\t>;\n\t},\n) {\n\tconst { watcher, publication: adapter, ...definition } = config;\n\tconst publication = createRepositoryChangePublication(adapter);\n\tpublication.fragment.watcher({\n\t\t...watcher,\n\t\tid: \"use_leitwerk\",\n\t\tlabel: `${label} use-leitwerk issues`,\n\t\tdescription: `Launch a remote repository change for ${label} issues carrying the trigger label`,\n\t});\n\tconst { process } = createRepositoryChangeProcess({\n\t\t...definition,\n\t\tpublication,\n\t\tprocessId: `${provider}_repo_change_process`,\n\t\tdisplayName: `${label} Repo Change`,\n\t\trepositoryCredentials: ({ params }) => [\n\t\t\t{ projectKey: \"repo\", kind: \"git_ssh\", credentialRef: params.sshCredentialRef },\n\t\t],\n\t});\n\tprocess.runtime = { ...process.runtime, docker };\n\treturn process;\n}\n\n/** Tools implementing the shared pull-request publication protocol. @internal */\nfunction pullRequestDeliveryTools(provider: string): string[] {\n\treturn [\n\t\t\"get_pull_request\",\n\t\t\"add_pull_request_comment\",\n\t\t\"resolve_git_identity\",\n\t\t\"ensure_pull_request\",\n\t\t\"add_issue_comment\",\n\t\t\"add_pull_request_feedback_reaction\",\n\t\t\"reply_to_pull_request_feedback\",\n\t\t\"get_issue\",\n\t\t\"ensure_label\",\n\t\t\"update_issue\",\n\t].map((name) => `${provider}_${name}`);\n}\n\nconst callFor =\n\t(ctx: Pick<PublicationContext<unknown>, \"callIntegrationTool\">, provider: string) =>\n\t<T>(name: string, args: Record<string, unknown>) =>\n\t\tctx.callIntegrationTool(`${provider}_${name}`, { projectKey: \"repo\", ...args }) as Promise<T>;\n\n/** @internal */\nexport async function resolvePullRequestGitIdentity<P>(\n\tctx: PublicationContext<P>,\n\tprovider: string,\n\tprofile: string,\n\tallowLookup = true,\n): Promise<GitIdentity> {\n\tconst project = ctx.repo.get(\"repo\");\n\tconst metadata = ctx.projects.find((candidate) => candidate.key === project.key)?.metadata;\n\tconst identity = object(metadata?.[\"leitwerk.gitIdentity\"]);\n\tif (\n\t\tidentity.provider === provider &&\n\t\tidentity.profile === profile &&\n\t\t(!allowLookup || (typeof identity.login === \"string\" && identity.login.trim())) &&\n\t\t[identity.name, identity.email].every((value) => typeof value === \"string\" && value.trim())\n\t)\n\t\treturn identity as unknown as GitIdentity;\n\tif (!allowLookup) throw new Error(`Pinned ${provider} Git identity is unavailable`);\n\treturn callFor(ctx, provider)<GitIdentity>(\"resolve_git_identity\", {});\n}\n\n/** @internal */\nfunction readPullRequestFeedback(\n\tcurrent: PublicationState,\n\tevent: unknown,\n): Extract<PublicationEvidence, { kind: \"feedback\" }> {\n\tconst value = object(event);\n\tconst cursors = object(value.cursors);\n\treturn {\n\t\tkind: \"feedback\",\n\t\tconversationCursor: Number(cursors.conversationCursor ?? current.conversationCursor),\n\t\treviewCursor: Number(cursors.reviewCursor ?? current.reviewCursor),\n\t\tinlineCursor: Number(cursors.inlineCursor ?? current.inlineCursor),\n\t\tfeedbackIds: (value.feedbackIds ?? []) as PublicationState[\"feedbackIds\"],\n\t};\n}\n\n/** @internal */\ntype SourceFactory<C> = ReturnType<typeof defineExternalActionSource<C>>;\n\n/** Shared wiring for providers implementing the pull-request source protocol. @internal */\nexport function pullRequestPublicationDefaults<P extends PublicationParams>(\n\tprovider: string,\n\tlabel: string,\n\texternal: {\n\t\t/** @internal */\n\t\tpullRequestFeedback: SourceFactory<\n\t\t\tOmit<RepositoryFeedbackSourceConfig, \"disabled\" | \"terminalOutcome\">\n\t\t>;\n\t\t/** @internal */\n\t\tpullRequestTerminal: SourceFactory<Omit<RepositoryPullRequestSourceConfig, \"disabled\">>;\n\t\t/** @internal */\n\t\tissueCancelled: SourceFactory<RepositoryIssueCancelledSourceConfig>;\n\t},\n\tprofile: (params: P) => string,\n\tissueOrigin: (params: P) => RepositoryIssueOriginParams | undefined,\n\tlabelKey: \"id\" | \"name\",\n\tci: {\n\t\t/** @internal */ id: string;\n\t\t/** @internal */ label: string;\n\t\t/** @internal */ tools: readonly string[];\n\t\t/** @internal */ prompt(current: PublicationState): string;\n\t},\n) {\n\tconst remote = (state: RepositoryChangeState) =>\n\t\treadPublicationState(state, `${provider}RepoChange`);\n\t/** @internal */\n\tfunction requirePr(state: RepositoryChangeState) {\n\t\tconst value = remote(state);\n\t\tif (!value.headSha || !value.prNumber || !value.prUrl)\n\t\t\tthrow new Error(\"Pull request delivery state is incomplete\");\n\t\treturn {\n\t\t\t...value,\n\t\t\t/** @internal */ headSha: value.headSha,\n\t\t\t/** @internal */ prNumber: value.prNumber,\n\t\t\t/** @internal */ prUrl: value.prUrl,\n\t\t};\n\t}\n\tconst feedback: PublicationSource<P> = {\n\t\tid: `${provider}_feedback`,\n\t\tkind: \"feedback\",\n\t\tlabel: `${label} pull request feedback`,\n\t\tsource: external.pullRequestFeedback<P, RepositoryChangeState>(({ params, state }) => ({\n\t\t\tprofile: profile(params),\n\t\t\towner: params.owner,\n\t\t\trepo: params.repo,\n\t\t\tprNumber: requirePr(state).prNumber,\n\t\t\tconversationCursor: remote(state).conversationCursor,\n\t\t\treviewCursor: remote(state).reviewCursor,\n\t\t\tinlineCursor: remote(state).inlineCursor,\n\t\t\tquietPeriodMs: 120000,\n\t\t\tpollInterval: \"30s\",\n\t\t})),\n\t\tread: ({ state, event }) => readPullRequestFeedback(remote(state), event),\n\t};\n\tconst terminal: PublicationSource<P>[] = ([\"merged\", \"closed\"] as const).map(\n\t\t(terminalOutcome) => ({\n\t\t\tid: `${provider}_pr_${terminalOutcome}`,\n\t\t\tkind: \"terminal\",\n\t\t\tlabel: `${label} pull request ${terminalOutcome}`,\n\t\t\tsource: external.pullRequestTerminal<P, RepositoryChangeState>(({ params, state }) => ({\n\t\t\t\tprofile: profile(params),\n\t\t\t\towner: params.owner,\n\t\t\t\trepo: params.repo,\n\t\t\t\tprNumber: requirePr(state).prNumber,\n\t\t\t\tterminalOutcome,\n\t\t\t\tpollInterval: \"30s\",\n\t\t\t})),\n\t\t\tread: ({ event }) => ({\n\t\t\t\tkind: \"terminal\",\n\t\t\t\trequest: object(event).pullRequest as PublicationRequest,\n\t\t\t}),\n\t\t}),\n\t);\n\tconst cancelled: PublicationSource<P> = {\n\t\tid: \"source_cancelled\",\n\t\tkind: \"cancelled\",\n\t\tlabel: \"Source issue cancelled\",\n\t\tenabled: (params) => issueOrigin(params) !== undefined,\n\t\tsource: external.issueCancelled<P, RepositoryChangeState>(({ params }) => {\n\t\t\tconst issue = issueOrigin(params);\n\t\t\tif (!issue) throw new Error(`${label} source issue metadata is unavailable`);\n\t\t\treturn {\n\t\t\t\tprofile: profile(params),\n\t\t\t\towner: params.owner,\n\t\t\t\trepo: params.repo,\n\t\t\t\tissueNumber: issue.issueNumber,\n\t\t\t\ttriggerLabel: issue.triggerLabel,\n\t\t\t\tpollInterval: \"30s\",\n\t\t\t};\n\t\t}),\n\t\tread: () => ({ kind: \"cancelled\" }),\n\t};\n\tasync function finalizeIssue(ctx: RemoteContext<P>, pr: PublicationRequest | null) {\n\t\tconst params = issueOrigin(ctx.params);\n\t\tif (!params) return;\n\t\tconst call = callFor(ctx, provider);\n\t\tconst issue = await call<{ labels: Array<{ id: number; name: string }> }>(\"get_issue\", {\n\t\t\tissueNumber: params.issueNumber,\n\t\t});\n\t\tlet labels = issue.labels\n\t\t\t.filter((label) => label.name !== params.triggerLabel)\n\t\t\t.map((label) => label[labelKey]);\n\t\tif (pr?.merged) {\n\t\t\tconst done = await call<{ id: number; name: string }>(\"ensure_label\", {\n\t\t\t\tname: params.doneLabel,\n\t\t\t});\n\t\t\tlabels = [...new Set([...labels, done[labelKey]])];\n\t\t}\n\t\tawait call(\"update_issue\", {\n\t\t\tissueNumber: params.issueNumber,\n\t\t\tpatch: { labels, ...(pr?.merged ? { state: \"closed\" } : {}) },\n\t\t\twriteKey: `${provider}:${ctx.process.id}:${pr?.merged ? \"complete-source-issue\" : pr ? \"remove-source-trigger\" : \"no-changes-trigger\"}`,\n\t\t});\n\t\tawait call(\"add_issue_comment\", {\n\t\t\tissueNumber: params.issueNumber,\n\t\t\tbody: !pr\n\t\t\t\t? \"No repository changes were needed. No pull request was opened.\"\n\t\t\t\t: pr.merged\n\t\t\t\t\t? `Merged ${pr.html_url}${pr.merge_commit_sha ? ` at ${pr.merge_commit_sha}` : \"\"}.`\n\t\t\t\t\t: `Leitwerk stopped because ${pr.html_url} was closed without merge.`,\n\t\t\twriteKey: `${provider}:${ctx.process.id}:${pr ? `${pr.merged ? \"merged\" : \"closed\"}-pr-comment` : \"no-changes-comment\"}`,\n\t\t});\n\t}\n\tconst call = (ctx: PublicationContext<P>) => callFor(ctx, provider);\n\tconst adapter: Omit<RepositoryChangePublicationAdapter<P>, \"sources\"> = {\n\t\t/** @internal */ namespace: `${provider}RepoChange`,\n\t\t/** @internal */ label: `${label} PR`,\n\t\t/** @internal */ ids: {\n\t\t\t/** @internal */ deliver: \"deliver_change\",\n\t\t\t/** @internal */ feedback: \"revise_from_pull_request_feedback\",\n\t\t\t/** @internal */ ciRepair: ci.id,\n\t\t\t/** @internal */ operator: \"ci_operator_action\",\n\t\t},\n\t\t/** @internal */ tools: {\n\t\t\t/** @internal */ delivery: pullRequestDeliveryTools(provider),\n\t\t\t/** @internal */ feedback: [\n\t\t\t\t`${provider}_get_pull_request`,\n\t\t\t\t`${provider}_list_pull_request_feedback`,\n\t\t\t],\n\t\t\t/** @internal */ ci: ci.tools,\n\t\t},\n\t\t/** @internal */ commitMessage: (kind: \"feedback\" | \"ci\") =>\n\t\t\tkind === \"feedback\" ? `fix: address ${label} review feedback` : `fix: repair ${ci.label}`,\n\t\t/** @internal */ prompt: (kind: \"feedback\" | \"ci\", current: PublicationState) =>\n\t\t\tkind === \"feedback\"\n\t\t\t\t? `Address the unseen ${label} pull-request feedback batch for PR #${current.prNumber}. Feedback identifiers: ${JSON.stringify(current.feedbackIds)}. Inspect the current checkout and use ${label} tools to read the full feedback. Do not rely on an earlier plan or conversation. Make only justified repository changes. Call changes_ready if files need publishing, no_changes after an explicit diagnosis that no repository change is needed, or cannot_repair when operator action is required.`\n\t\t\t\t: ci.prompt(current),\n\t\t/** @internal */ identity: (ctx: PublicationContext<P>) =>\n\t\t\tresolvePullRequestGitIdentity(ctx, provider, profile(ctx.params)),\n\t\t/** @internal */ reconcileTerminal: (ctx, _current, pr) => finalizeIssue(ctx, pr),\n\t\t/** @internal */ unchanged: (ctx) => finalizeIssue(ctx, null),\n\t\tasync ensureRequest(ctx) {\n\t\t\tconst project = ctx.repo.get(\"repo\");\n\t\t\tconst issue = issueOrigin(ctx.params);\n\t\t\tconst pr = await call(ctx)<PublicationRequest>(\"ensure_pull_request\", {\n\t\t\t\ttitle: ctx.process.title ?? (issue ? `Issue #${issue.issueNumber}` : \"Leitwerk change\"),\n\t\t\t\tbody: issue\n\t\t\t\t\t? `Implements ${issue.issueUrl}\\n\\nLeitwerk process: ${ctx.process.id}`\n\t\t\t\t\t: `Leitwerk process: ${ctx.process.id}`,\n\t\t\t\thead: project.workBranch,\n\t\t\t\tbase: project.baseBranch,\n\t\t\t});\n\t\t\tif (!pr) throw new Error(`${label} pull request could not be created or found`);\n\t\t\treturn pr;\n\t\t},\n\t\tasync linkIssue(ctx, current) {\n\t\t\tconst issue = issueOrigin(ctx.params);\n\t\t\tif (issue)\n\t\t\t\tawait call(ctx)(\"add_issue_comment\", {\n\t\t\t\t\tissueNumber: issue.issueNumber,\n\t\t\t\t\tbody: `Leitwerk opened pull request ${current.prUrl}.`,\n\t\t\t\t\twriteKey: `${provider}:${ctx.process.id}:source-pr-link:${current.prNumber}`,\n\t\t\t\t});\n\t\t},\n\t\tasync reply(ctx, current) {\n\t\t\tconst invoke = call(ctx);\n\t\t\tfor (const feedback of current.feedbackIds)\n\t\t\t\tawait invoke(\"reply_to_pull_request_feedback\", {\n\t\t\t\t\tpullRequestNumber: current.prNumber,\n\t\t\t\t\tfeedbackKind: feedback.kind,\n\t\t\t\t\tfeedbackId: feedback.id,\n\t\t\t\t\tbody: `Addressed in ${current.headSha?.slice(0, 8) ?? \"the current revision\"}.`,\n\t\t\t\t\twriteKey: `${provider}:${ctx.process.id}:feedback-reply:${feedback.kind}:${feedback.id}:${current.headSha}`,\n\t\t\t\t});\n\t\t},\n\t\tasync acknowledge(ctx, current) {\n\t\t\tconst invoke = call(ctx);\n\t\t\tfor (const feedback of current.feedbackIds) {\n\t\t\t\tif (feedback.kind === \"review\") continue;\n\t\t\t\tawait invoke(\"add_pull_request_feedback_reaction\", {\n\t\t\t\t\tpullRequestNumber: current.prNumber,\n\t\t\t\t\tfeedbackKind: feedback.kind,\n\t\t\t\t\tfeedbackId: feedback.id,\n\t\t\t\t\twriteKey: `${provider}:${ctx.process.id}:feedback-eyes:${feedback.kind}:${feedback.id}`,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tasync head(ctx, current) {\n\t\t\treturn (\n\t\t\t\tawait call(ctx)<{ head: { sha: string } }>(\"get_pull_request\", {\n\t\t\t\t\tpullRequestNumber: current.prNumber,\n\t\t\t\t})\n\t\t\t).head.sha;\n\t\t},\n\t\tasync afterRebase(ctx, current) {\n\t\t\tawait call(ctx)(\"add_pull_request_comment\", {\n\t\t\t\tpullRequestNumber: current.prNumber,\n\t\t\t\tbody: `Merge conflict repair completed at ${current.headSha}; base ${current.conflict?.baseSha}.`,\n\t\t\t\twriteKey: `rebase:${ctx.process.id}:${current.lastConflictKey}:${current.headSha}`,\n\t\t\t});\n\t\t},\n\t};\n\treturn {\n\t\t/** @internal */ adapter,\n\t\t/** @internal */ conflict(source: PublicationSource<P>[\"source\"]): PublicationSource<P> {\n\t\t\treturn {\n\t\t\t\tid: `${provider}_merge_conflict`,\n\t\t\t\tkind: \"conflict\",\n\t\t\t\tlabel: \"Rebase conflicting pull request\",\n\t\t\t\tsource,\n\t\t\t\tread: ({ event }) => ({\n\t\t\t\t\tkind: \"conflict\",\n\t\t\t\t\tconflict: object(event).conflict as NonNullable<PublicationState[\"conflict\"]>,\n\t\t\t\t}),\n\t\t\t};\n\t\t},\n\t\t/** @internal */ requirePr,\n\t\t/** @internal */ feedback,\n\t\t/** @internal */ terminal,\n\t\t/** @internal */ cancelled,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,uBAAuB;AAChC;AAAA,EAKC;AAAA,OAEM;;;ACRP,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,mBAAmB,kCAAkC;AAC9D,SAAS,wBAAwB;;;ACmB1B,SAAS,oBACf,YACA,UACA,QACO;AACP,MAAI,eAAe,SAAS,cAAc,eAAe,SAAS;AACjE,UAAM,IAAI,MAAM,mEAAmE;AACpF,MAAI,WAAW,OAAO,WAAW,cAAc,OAAO,iBAAiB,SAAS;AAC/E,UAAM,IAAI,MAAM,kCAAkC;AACnD,MAAI,QAAQ,cAAc,OAAO,eAAe,SAAS;AACxD,UAAM,IAAI,MAAM,8CAA8C;AAChE;AAGO,SAAS,oBACf,QACA,QACO;AACP,MACE,QAAQ,aAAa,OAAO,cAAc,OAAO,aACjD,QAAQ,iBAAiB,OAAO,kBAAkB,OAAO;AAE1D,UAAM,IAAI,MAAM,yCAAyC;AAC3D;AAGO,SAAS,sBACf,YACA,aACO;AACP,MAAI,YAAY,WAAW,WAAY,OAAM,IAAI,MAAM,yCAAyC;AAChG,MAAI,YAAY;AACf,UAAM,IAAI,MAAM,+DAA+D;AACjF;AAGO,SAAS,kBAAkB,UAAkB,OAAe,QAAsB;AACxF,MAAI,WAAW,YAAY,UAAU;AACpC,UAAM,IAAI,MAAM,sCAAsC;AACxD;;;AD1BA,SAAS,IAAI,UAAuB,MAAwB;AAC3D,SAAO,aAAa,iBAAiB,GAAG,kBAAkB,IAAI,GAAG;AAAA,IAChE,KAAK,MAAM;AAAA,IACX,UAAU;AAAA,IACV,KAAK,2BAA2B,MAAM,YAAY;AAAA,MACjD,qBA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A;AAAA,IAGV,WAAW,CAAC,IAAI,OAAO;AAAA,EACxB;AACD;","names":["call","label","feedback","label","outcome","state"]}
1
+ {"version":3,"sources":["../src/repository-change-publication.ts","../src/repository-rebase/git.ts","../src/repository-rebase/policy.ts","../src/repository-rebase/prompt.ts","../src/pull-request-publication-internal.ts"],"sourcesContent":["import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\ttype AutomaticOutcomeBuilder,\n\ttype ExtensionProcessDefinition,\n\ttype ExternalActionSource,\n\ttype FlowAutomaticRunContext,\n\tflow,\n\ttype ServerExtensionAPI,\n} from \"@leitwerk-dev/process-sdk\";\nimport {\n\tcommitAndPushWorkBranch,\n\ttype GitIdentity,\n\trepositoryHasChanges,\n} from \"./finalization-git.js\";\nimport { RemoteBranchChangedError } from \"./finalization-git-internal.js\";\nimport type { RepositoryChangeState } from \"./repository-change-state.js\";\nimport {\n\tConcurrentRebaseSourceError,\n\thasPreparedRebase,\n\tpublishRebase,\n\tstartRebase,\n} from \"./repository-rebase/git.js\";\nimport { type ConflictEvidence, conflictKey, validateConflict } from \"./repository-rebase/index.js\";\nimport { rebasePrompt } from \"./repository-rebase/prompt.js\";\nimport {\n\treconcilePublicationRepository,\n\treconciliationPrompt,\n\trecordRepositoryPublication,\n\trepositoryWorktreeIsDirty,\n\tretainConcurrentRebase,\n} from \"./repository-reconciliation.js\";\nimport { codingPurposes } from \"./settings.js\";\nimport { prepareSubmodules } from \"./submodule-staging.js\";\n\nexport {\n\tcreatePullRequestChangeProcess,\n\tpullRequestPublicationDefaults,\n\tresolvePullRequestGitIdentity,\n} from \"./pull-request-publication-internal.js\";\n\n/** @public */\nexport interface PublicationRequest {\n\t/** @public */\n\tnumber: number;\n\n\t/** @public */\n\thtml_url: string;\n\n\t/** @public */\n\tmerged: boolean;\n\n\t/** @public */\n\tmerge_commit_sha?: string | null;\n}\n\n/** @public */\nexport interface PublicationPipeline {\n\t/** @public */\n\tnumber: number;\n\n\t/** @public */\n\tstatus: string;\n\n\t/** @public */\n\t[key: string]: unknown;\n}\n\n/** @public */\nexport interface PublicationParams {\n\t/** @public */\n\towner: string;\n\n\t/** @public */\n\trepo: string;\n\n\t/** @public */\n\tworkBranch: string;\n\n\t/** @public */\n\tbaseBranch: string;\n}\n\n/** Narrow process params to a resolved repository before publication. @public */\nexport function requirePublicationParams<P>(params: P): P & PublicationParams {\n\tconst value = asUnknownRecord(params);\n\tfor (const key of [\"owner\", \"repo\", \"workBranch\", \"baseBranch\"])\n\t\tif (typeof value?.[key] !== \"string\" || !value[key])\n\t\t\tthrow new Error(\"Repository binding is not resolved\");\n\treturn params as P & PublicationParams;\n}\n\n/** @public */\nexport type PublicationContext<P> = FlowAutomaticRunContext<P, RepositoryChangeState>;\n\n/** Remote reconciliation has no worker checkout or filesystem access. @public */\nexport type PublicationReconciliationContext<P> = Pick<\n\tPublicationContext<P>,\n\t\"process\" | \"projects\" | \"params\" | \"state\" | \"callIntegrationTool\"\n>;\n\n/** @public */\nexport type PublicationEvidence = (\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"feedback\";\n\n\t\t\t/** @public */\n\t\t\tfeedbackIds: PublicationFeedbackId[];\n\n\t\t\t/** @public */\n\t\t\tconversationCursor: number;\n\n\t\t\t/** @public */\n\t\t\treviewCursor: number;\n\n\t\t\t/** @public */\n\t\t\tinlineCursor: number;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"failure\";\n\n\t\t\t/** @public */\n\t\t\tpipeline: PublicationPipeline;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"conflict\";\n\n\t\t\t/** @public */\n\t\t\tconflict: ConflictEvidence;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"terminal\";\n\n\t\t\t/** @public */\n\t\t\trequest: PublicationRequest;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"cancelled\";\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"observed\";\n\t }\n) & {\n\t/** @public */\n\tobservationKey?: string;\n\t/** Current provider source revision. @internal */ remoteHeadSha?: string;\n\t/** Coordinated repository key. @public */ projectKey?: string;\n};\n\n/** @public */\nexport interface PublicationSource<P> {\n\t/** @public */\n\tid: string;\n\n\t/** @public */\n\tkind: \"feedback\" | \"failure\" | \"conflict\" | \"terminal\" | \"cancelled\" | \"observation\";\n\n\t/** @public */\n\toperatorId?: string;\n\n\t/** @public */\n\tlabel: string;\n\n\t/** @public */\n\tsource: ExternalActionSource<P, RepositoryChangeState, unknown>;\n\n\t/** @public */\n\tenabled?(params: P, state: RepositoryChangeState): boolean;\n\n\t/** @public */\n\tread(input: {\n\t\t/** @public */\n\t\tparams: P;\n\n\t\t/** @public */\n\t\tstate: RepositoryChangeState;\n\n\t\t/** @public */\n\t\tevent: unknown;\n\t}): PublicationEvidence;\n}\n\n/** @public */\nexport interface RepositoryChangePublicationAdapter<P> {\n\t/** Optional server maintenance uses existing business turns and adds no worker positions. @public */\n\tmaintenance?: {\n\t\t/** @public */ source: ExternalActionSource<\n\t\t\tP,\n\t\t\tRepositoryChangeState,\n\t\t\tPublicationMaintenanceEvent\n\t\t>;\n\t\t/** @public */ ownershipTool: string;\n\t\t/** @public */ register(\n\t\t\tapi: ServerExtensionAPI,\n\t\t\tprocess: ExtensionProcessDefinition<P, RepositoryChangeState>,\n\t\t): void;\n\t};\n\t/** @public */\n\tnamespace: string;\n\t/** Prepare pinned submodules after revision reconciliation. @public */\n\tprepareSubmodules?: boolean;\n\t/** Reconcile a single-repository no-change outcome. @public */\n\tunchanged?(ctx: PublicationContext<P>): Promise<void>;\n\t/** Optional coordinated repositories; each retains independent publication state. @public */\n\trepositories?(params: P): readonly {\n\t\t/** @internal */\n\t\tkey: string;\n\t\t/** @internal */\n\t\tparams: P & PublicationParams;\n\t}[];\n\t/** Reconcile remote terminal state before new writes or source cancellation. @public */\n\tobserveTerminal?(\n\t\tctx: PublicationContext<P>,\n\t\tcurrent: PublicationState,\n\t): Promise<PublicationRequest | null>;\n\n\t/** @public */\n\tsourceCancelled?(ctx: PublicationReconciliationContext<P>): Promise<boolean>;\n\n\t/** @public */\n\treconcileAll?(\n\t\tctx: PublicationReconciliationContext<P>,\n\t\tresults: readonly {\n\t\t\t/** @internal */\n\t\t\tkey: string;\n\t\t\t/** @internal */\n\t\t\tcurrent: PublicationState;\n\t\t}[],\n\t\tcancelled: boolean,\n\t): Promise<void>;\n\n\t/** @public */\n\tlabel: string;\n\n\t/** @public */\n\tids: {\n\t\t/** @public */\n\t\tdeliver: string;\n\n\t\t/** @public */\n\t\tfeedback: string;\n\n\t\t/** @public */\n\t\tciRepair: string;\n\n\t\t/** @public */\n\t\toperator: string;\n\t};\n\n\t/** @public */\n\ttools: {\n\t\t/** @public */\n\t\tdelivery: readonly string[];\n\n\t\t/** @public */\n\t\tfeedback: readonly string[];\n\n\t\t/** @public */\n\t\tci: readonly string[];\n\t};\n\n\t/** @public */\n\tsources: readonly PublicationSource<P>[];\n\n\t/** @public */\n\tidentity(ctx: PublicationContext<P>): Promise<GitIdentity>;\n\n\t/** @public */\n\tensureRequest(ctx: PublicationContext<P>): Promise<PublicationRequest>;\n\n\t/** @public */\n\treconcileTerminal(\n\t\tctx: PublicationReconciliationContext<P>,\n\t\tcurrent: PublicationState,\n\t\trequest: PublicationRequest,\n\t): Promise<void>;\n\n\t/** @public */\n\tlinkIssue(ctx: PublicationContext<P>, current: PublicationState): Promise<void>;\n\n\t/** @public */\n\tacknowledge(ctx: PublicationContext<P>, current: PublicationState): Promise<void>;\n\n\t/** @public */\n\treply(ctx: PublicationContext<P>, current: PublicationState): Promise<void>;\n\n\t/** @public */\n\tafterRebase(ctx: PublicationContext<P>, current: PublicationState): Promise<void>;\n\n\t/** @public */\n\thead(ctx: PublicationContext<P>, current: PublicationState): Promise<string>;\n\n\t/** @public */\n\tprompt(kind: \"feedback\" | \"ci\", current: PublicationState): string;\n\n\t/** @public */\n\tcommitMessage(kind: \"feedback\" | \"ci\"): string;\n}\n\n/** @public */\nexport interface PublicationMaintenanceEvent {\n\t/** @public */\n\tstate: RepositoryChangeState;\n}\n\n/** @public */\nexport interface FeedbackDeliveryResult {\n\t/** @public */\n\tpublished: boolean;\n\t/** @public */\n\tsummary: string;\n}\n\n/** @public */\nexport type PublicationFeedbackId = {\n\t/** @public */\n\tkind: \"conversation\" | \"review\" | \"inline\";\n\n\t/** @public */\n\tid: number;\n\n\t/** @public */\n\tdiscussionId?: string;\n};\n\n/** @public */\ntype AdjustmentInvocation = {\n\t/** @public */\n\torigin: \"feedback\" | \"ci\" | \"rebase\";\n\n\t/** @public */\n\tpublishRequired: boolean;\n\t/** Operator-facing no-change diagnosis retained until delivery. @internal */\n\tsummary?: string;\n};\n\n/** @public */\nexport interface DeliveryState {\n\t/** Feedback delivery retained until the server acknowledges the batch. @public */\n\tfeedbackResult?: FeedbackDeliveryResult | null;\n\t/** @public */\n\tstage: \"not_started\" | \"branch_published\" | \"pull_request_ready\" | \"awaiting\";\n\n\t/** @public */\n\tissueLinked: boolean;\n\n\t/** @public */\n\tadjustment: AdjustmentInvocation | null;\n\n\t/** @public */\n\tterminalPullRequest: PublicationRequest | null;\n}\n\n/** @public */\nexport interface PublicationState {\n\t/** Maintenance was stopped for this MR; it remains open and contributes a partial result. @public */ stopped?: boolean;\n\t/** Repository had no change at first publication. @public */ noChanges?: boolean;\n\n\t/** @public */\n\tlastConflictKey?: string | null;\n\n\t/** @public */\n\tconflict?: ConflictEvidence | null;\n\n\t/** @public */\n\trepairReason?: \"feedback\" | \"ci\" | \"rebase\";\n\t/** Staged repair retained when another maintained MR interrupts the worker. @public */\n\trepairPending?: boolean;\n\n\t/** @public */\n\theadSha: string | null;\n\n\t/** Baseline retained until the worker reconciles its unpublished delta. @internal */\n\tworkBaselineSha?: string | null;\n\t/** Historical publication receipt, not an eligibility condition. @internal */\n\tlastPublishedHeadSha?: string | null;\n\t/** Combined tree needs validation before publication. @internal */\n\treconciliationRequired?: boolean;\n\t/** Bound automatic reconciliation loops under continuously moving branches. @internal */\n\treconciliationCycles?: number;\n\n\t/** @public */\n\tprNumber: number | null;\n\n\t/** @public */\n\tprUrl: string | null;\n\n\t/** @public */\n\tconversationCursor: number;\n\n\t/** @public */\n\treviewCursor: number;\n\n\t/** @public */\n\tinlineCursor: number;\n\n\t/** @public */\n\tfeedbackIds: PublicationFeedbackId[];\n\n\t/** @public */\n\tpipeline: PublicationPipeline | null;\n\n\t/** @public */\n\tciRecoveryCycles: number;\n\n\t/** @public */\n\tdelivery: DeliveryState;\n\n\t/** @public */\n\tobservationKey?: string;\n\n\t/** @public */\n\tpendingEvidence?: PublicationEvidence | null;\n}\n\nconst initialDeliveryState: DeliveryState = {\n\tstage: \"not_started\",\n\tissueLinked: false,\n\tadjustment: null,\n\tterminalPullRequest: null,\n};\n\nconst initialPublicationState: PublicationState = {\n\theadSha: null,\n\tprNumber: null,\n\tprUrl: null,\n\tconversationCursor: 0,\n\treviewCursor: 0,\n\tinlineCursor: 0,\n\tfeedbackIds: [],\n\tpipeline: null,\n\tciRecoveryCycles: 0,\n\tdelivery: initialDeliveryState,\n};\n\n/** @public */\nexport const publicationObject = (value: unknown) => asUnknownRecord(value) ?? {};\n\n/** Shared coordination metadata for worker publication and server maintenance. @internal */\nexport function createPublicationSelection(namespace: () => string) {\n\treturn {\n\t\t/** @internal */\n\t\tactiveKey: (state: RepositoryChangeState) =>\n\t\t\tpublicationObject(state.extensionState?.[`${namespace()}.coordination`]).activeKey as\n\t\t\t\t| string\n\t\t\t\t| undefined,\n\t\t/** @internal */\n\t\tselect: (state: RepositoryChangeState, key: string): RepositoryChangeState => ({\n\t\t\t...state,\n\t\t\textensionState: {\n\t\t\t\t...state.extensionState,\n\t\t\t\t[`${namespace()}.coordination`]: { activeKey: key },\n\t\t\t},\n\t\t}),\n\t};\n}\n\n/** @internal */\nexport const publicationFinished = (current: PublicationState): boolean =>\n\t!!(current.stopped || current.noChanges || current.delivery.terminalPullRequest);\n\n/** @public */\nexport function readPublicationState(\n\tstate: RepositoryChangeState,\n\tnamespace: string,\n): PublicationState {\n\tconst stored = publicationObject(publicationObject(state.extensionState)[namespace]);\n\treturn {\n\t\t...initialPublicationState,\n\t\t...stored,\n\t\tdelivery: {\n\t\t\t...initialDeliveryState,\n\t\t\t...publicationObject(stored.delivery),\n\t\t},\n\t} as PublicationState;\n}\n\n/** @public */\nexport function patchPublicationState(\n\tstate: RepositoryChangeState,\n\tnamespace: string,\n\tpatch: Partial<Omit<PublicationState, \"delivery\">> & {\n\t\t/** @public */\n\t\tdelivery?: Partial<DeliveryState>;\n\t},\n): RepositoryChangeState {\n\tconst current = readPublicationState(state, namespace);\n\treturn {\n\t\t...state,\n\t\textensionState: {\n\t\t\t...state.extensionState,\n\t\t\t[namespace]: {\n\t\t\t\t...current,\n\t\t\t\t...patch,\n\t\t\t\tdelivery: { ...current.delivery, ...patch.delivery },\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** @public */\nexport function applyPublicationEvidence(\n\tparams: unknown,\n\tcurrent: PublicationState,\n\tevidence: PublicationEvidence,\n\tcountFailure = true,\n): PublicationState {\n\tif (evidence.observationKey !== undefined)\n\t\tcurrent = { ...current, observationKey: evidence.observationKey };\n\tif (evidence.remoteHeadSha && evidence.remoteHeadSha !== current.headSha)\n\t\tcurrent = {\n\t\t\t...current,\n\t\t\tworkBaselineSha: current.workBaselineSha ?? current.headSha,\n\t\t\tlastPublishedHeadSha: current.lastPublishedHeadSha ?? current.headSha,\n\t\t\theadSha: evidence.remoteHeadSha,\n\t\t\tpipeline: null,\n\t\t};\n\tswitch (evidence.kind) {\n\t\tcase \"feedback\": {\n\t\t\tconst { kind: _, ...batch } = evidence;\n\t\t\treturn { ...current, ...batch, repairReason: \"feedback\" };\n\t\t}\n\t\tcase \"failure\":\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\trepairReason: \"ci\",\n\t\t\t\tpipeline: evidence.pipeline,\n\t\t\t\tciRecoveryCycles: current.ciRecoveryCycles + (countFailure ? 1 : 0),\n\t\t\t};\n\t\tcase \"conflict\": {\n\t\t\tconst repository = requirePublicationParams(params);\n\t\t\tconst conflict = validateConflict(\n\t\t\t\tevidence.conflict,\n\t\t\t\t{\n\t\t\t\t\towner: repository.owner,\n\t\t\t\t\trepo: repository.repo,\n\t\t\t\t\tprNumber: current.prNumber ?? 0,\n\t\t\t\t\theadSha: current.headSha ?? \"\",\n\t\t\t\t\theadBranch: repository.workBranch,\n\t\t\t\t\tbaseBranch: repository.baseBranch,\n\t\t\t\t},\n\t\t\t\tcurrent.lastConflictKey,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\tconflict,\n\t\t\t\tlastConflictKey: conflictKey(conflict),\n\t\t\t\trepairReason: \"rebase\",\n\t\t\t};\n\t\t}\n\t\tcase \"terminal\":\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\tdelivery: { ...current.delivery, terminalPullRequest: evidence.request },\n\t\t\t};\n\t\tdefault:\n\t\t\treturn current;\n\t}\n}\nfunction deliveryProgress(value: PublicationState, label: string, activeStepId?: string) {\n\tconst delivery = value.delivery;\n\tconst step = (id: string, label: string, done: boolean) => ({\n\t\tid,\n\t\tlabel,\n\t\tstatus: (activeStepId === id ? \"in_progress\" : done ? \"completed\" : \"incomplete\") as\n\t\t\t| \"in_progress\"\n\t\t\t| \"completed\"\n\t\t\t| \"incomplete\",\n\t});\n\tconst adjustmentHandled =\n\t\tdelivery.adjustment === null && delivery.stage === \"awaiting\" && value.headSha !== null;\n\treturn {\n\t\ttitle: \"Delivery progress\",\n\t\tsteps: [\n\t\t\tstep(\"publish_branch\", \"Publish work branch\", value.headSha !== null),\n\t\t\tstep(\"open_pr\", \"Create or find pull request\", value.prNumber !== null),\n\t\t\tstep(\"link_issue\", \"Link source issue when applicable\", delivery.issueLinked),\n\t\t\tstep(\"publish_adjustment\", \"Publish an adjustment when applicable\", adjustmentHandled),\n\t\t\tstep(\n\t\t\t\t\"reply_feedback\",\n\t\t\t\t\"Acknowledge or reply to feedback when applicable\",\n\t\t\t\tvalue.feedbackIds.length === 0,\n\t\t\t),\n\t\t\tstep(\"await_evidence\", \"Await external evidence\", delivery.stage === \"awaiting\"),\n\t\t\tstep(\n\t\t\t\t\"reconcile_terminal\",\n\t\t\t\t\"Reconcile terminal pull request\",\n\t\t\t\tdelivery.terminalPullRequest !== null,\n\t\t\t),\n\t\t],\n\t\t...(value.prNumber && value.prUrl\n\t\t\t? {\n\t\t\t\t\tlinks: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: `${label}-pr-${value.prNumber}`,\n\t\t\t\t\t\t\tlabel: `${label} #${value.prNumber}`,\n\t\t\t\t\t\t\turl: value.prUrl,\n\t\t\t\t\t\t\tkind: \"pull_request\" as const,\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/** @public */\nexport function createRepositoryChangePublication<P>(\n\tadapter: RepositoryChangePublicationAdapter<P>,\n) {\n\tconst ids = adapter.ids;\n\tconst publication = flow.fragment<P, RepositoryChangeState>(`${adapter.namespace}-publication`);\n\tconst { activeKey, select } = createPublicationSelection(() => adapter.namespace);\n\tconst namespace = (state: RepositoryChangeState) =>\n\t\tadapter.repositories ? `${adapter.namespace}:${activeKey(state)}` : adapter.namespace;\n\tconst remote = (state: RepositoryChangeState) => readPublicationState(state, namespace(state));\n\tconst repositoryContext = (ctx: PublicationContext<P>): PublicationContext<P> => {\n\t\tif (!adapter.repositories) return ctx;\n\t\tconst selected = adapter\n\t\t\t.repositories(ctx.params)\n\t\t\t.find((repo) => repo.key === activeKey(ctx.state));\n\t\tif (!selected) throw new Error(\"Missing coordinated repository selection\");\n\t\treturn {\n\t\t\t...ctx,\n\t\t\tparams: selected.params,\n\t\t\trepo: { ...ctx.repo, get: (key) => ctx.repo.get(key === \"repo\" ? selected.key : key) },\n\t\t\tcallIntegrationTool: (name, args) =>\n\t\t\t\tctx.callIntegrationTool(name, { ...args, projectKey: selected.key }),\n\t\t};\n\t};\n\tconst patchRemote = (\n\t\tstate: RepositoryChangeState,\n\t\tpatch: Partial<Omit<PublicationState, \"delivery\">> & { delivery?: Partial<DeliveryState> },\n\t) => patchPublicationState(state, namespace(state), patch);\n\tasync function commitWorkBranch(\n\t\tctx: PublicationContext<P>,\n\t\tcommitMessage: string,\n\t\texpectedRemoteHead = remote(ctx.state).headSha,\n\t) {\n\t\tconst repo = ctx.repo.get(\"repo\");\n\t\tconst gitIdentity = await adapter.identity(ctx);\n\t\tif (adapter.maintenance)\n\t\t\tawait ctx.callIntegrationTool(adapter.maintenance.ownershipTool, { projectKey: repo.key });\n\t\treturn commitAndPushWorkBranch({\n\t\t\trepoPath: repo.fsPath,\n\t\t\tprojectKey: repo.key,\n\t\t\tworkBranch: repo.workBranch,\n\t\t\tcommitMessage,\n\t\t\tgitIdentity,\n\t\t\texpectedRemoteHead,\n\t\t\tprotectSubmodules: adapter.prepareSubmodules,\n\t\t});\n\t}\n\tasync function reconcile(ctx: PublicationContext<P>, current: PublicationState) {\n\t\tconst repo = ctx.repo.get(\"repo\");\n\t\treturn reconcilePublicationRepository({\n\t\t\tprojectKey: repo.key,\n\t\t\trepoPath: repo.fsPath,\n\t\t\tworkBranch: repo.workBranch,\n\t\t\tbaseBranch: repo.baseBranch,\n\t\t\tbaselineSha: current.workBaselineSha ?? current.headSha ?? undefined,\n\t\t\tgitIdentity: await adapter.identity(ctx),\n\t\t\tprotectSubmodules: adapter.prepareSubmodules,\n\t\t});\n\t}\n\tconst runRepository = async (ctx: PublicationContext<P>) => {\n\t\tlet current = remote(ctx.state);\n\t\tconst update = (patch: Parameters<typeof patchRemote>[1]) => {\n\t\t\tcurrent = { ...current, ...patch, delivery: { ...current.delivery, ...patch.delivery } };\n\t\t};\n\t\tconst acknowledgePublication = (headSha: string, changed: boolean) => {\n\t\t\tupdate({\n\t\t\t\theadSha,\n\t\t\t\tworkBaselineSha: headSha,\n\t\t\t\tlastPublishedHeadSha: changed ? headSha : current.lastPublishedHeadSha,\n\t\t\t\treconciliationRequired: false,\n\t\t\t\treconciliationCycles: 0,\n\t\t\t\tpipeline: changed ? null : current.pipeline,\n\t\t\t});\n\t\t\tconst repo = ctx.repo.get(\"repo\");\n\t\t\trecordRepositoryPublication(\n\t\t\t\t{\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},\n\t\t\t\theadSha,\n\t\t\t);\n\t\t};\n\t\tconst result = (\n\t\t\toutcome:\n\t\t\t\t| \"awaiting\"\n\t\t\t\t| \"feedback_ready\"\n\t\t\t\t| \"completed\"\n\t\t\t\t| \"aborted\"\n\t\t\t\t| \"ci_ready\"\n\t\t\t\t| \"conflict_ready\"\n\t\t\t\t| \"operator_action\",\n\t\t) => ({\n\t\t\toutcome,\n\t\t\tparams: { nextState: patchRemote(ctx.state, current) },\n\t\t});\n\t\tif (current.stopped) return result(\"aborted\");\n\t\tif (current.pendingEvidence) {\n\t\t\tconst evidence = current.pendingEvidence;\n\t\t\tconst needsOperator = evidence.kind === \"failure\" && current.ciRecoveryCycles >= 3;\n\t\t\tcurrent = applyPublicationEvidence(ctx.params, current, evidence, !needsOperator);\n\t\t\tcurrent.pendingEvidence = null;\n\t\t\tif (evidence.kind === \"cancelled\") return result(\"aborted\");\n\t\t\tif (evidence.kind === \"failure\")\n\t\t\t\treturn result(needsOperator ? \"operator_action\" : \"ci_ready\");\n\t\t\tif (evidence.kind === \"conflict\") return result(\"conflict_ready\");\n\t\t}\n\t\tctx.reportProgress(deliveryProgress(current, adapter.label));\n\t\tconst reconcileAgain = () => {\n\t\t\tconst cycles = (current.reconciliationCycles ?? 0) + 1;\n\t\t\tupdate({\n\t\t\t\treconciliationRequired: true,\n\t\t\t\treconciliationCycles: cycles,\n\t\t\t\trepairPending: true,\n\t\t\t\tconflict: null,\n\t\t\t\tlastConflictKey: null,\n\t\t\t\tpipeline: null,\n\t\t\t\tdelivery: { adjustment: null, feedbackResult: null },\n\t\t\t});\n\t\t\treturn result(cycles > 3 ? \"operator_action\" : \"conflict_ready\");\n\t\t};\n\n\t\tif (current.delivery.terminalPullRequest) {\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"reconcile_terminal\"));\n\t\t\tconst pr = current.delivery.terminalPullRequest;\n\t\t\tawait adapter.reconcileTerminal(ctx, current, pr);\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label));\n\t\t\treturn result(pr.merged ? \"completed\" : \"aborted\");\n\t\t}\n\n\t\tif (\n\t\t\t!current.headSha &&\n\t\t\t(adapter.repositories || adapter.unchanged) &&\n\t\t\t!repositoryHasChanges(\n\t\t\t\tctx.repo.get(\"repo\").fsPath,\n\t\t\t\tctx.repo.get(\"repo\").baseBranch,\n\t\t\t\tctx.repo.get(\"repo\").key,\n\t\t\t)\n\t\t) {\n\t\t\tupdate({ noChanges: true });\n\t\t\tawait adapter.unchanged?.(ctx);\n\t\t\treturn result(\"completed\");\n\t\t}\n\t\tlet publicationLease = current.headSha;\n\t\tif (\n\t\t\t(!current.headSha || current.delivery.adjustment) &&\n\t\t\tcurrent.delivery.adjustment?.origin !== \"rebase\"\n\t\t) {\n\t\t\tconst synchronized = await reconcile(ctx, current);\n\t\t\tif (synchronized.status !== \"unchanged\") return reconcileAgain();\n\t\t\t// Fetch is authoritative even if the watcher has not observed a developer push yet.\n\t\t\tpublicationLease = synchronized.remoteHead;\n\t\t\tif (current.headSha && synchronized.remoteHead && current.headSha !== synchronized.remoteHead)\n\t\t\t\tupdate({ headSha: synchronized.remoteHead, workBaselineSha: synchronized.remoteHead });\n\t\t}\n\t\tif (!current.headSha) {\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"publish_branch\"));\n\t\t\tlet published: { headSha: string };\n\t\t\ttry {\n\t\t\t\tpublished = await commitWorkBranch(\n\t\t\t\t\tctx,\n\t\t\t\t\tctx.state.finalization.commitMessages?.[ctx.repo.get(\"repo\").key] ??\n\t\t\t\t\t\tctx.state.finalization.generatedCommitMessage ??\n\t\t\t\t\t\t\"\",\n\t\t\t\t\tpublicationLease,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof RemoteBranchChangedError)) throw error;\n\t\t\t\treturn reconcileAgain();\n\t\t\t}\n\t\t\tacknowledgePublication(published.headSha, true);\n\t\t}\n\n\t\tif (!current.prNumber || !current.prUrl) {\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"open_pr\"));\n\t\t\tconst pr = await adapter.ensureRequest(ctx);\n\t\t\tupdate({ prNumber: pr.number, prUrl: pr.html_url });\n\t\t}\n\n\t\tif (!current.delivery.issueLinked) {\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"link_issue\"));\n\t\t\tawait adapter.linkIssue(ctx, current);\n\t\t\tupdate({ delivery: { issueLinked: true } });\n\t\t}\n\n\t\tif (current.delivery.adjustment) {\n\t\t\tconst adjustment = current.delivery.adjustment;\n\t\t\tif (adjustment.origin === \"rebase\" && !hasPreparedRebase(rebaseInput(ctx)))\n\t\t\t\treturn reconcileAgain();\n\t\t\tlet adjustmentPublished = false;\n\t\t\tif (adjustment.publishRequired || adjustment.origin === \"rebase\" || adapter.maintenance) {\n\t\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"publish_adjustment\"));\n\t\t\t\tif (adapter.maintenance)\n\t\t\t\t\tawait ctx.callIntegrationTool(adapter.maintenance.ownershipTool, {\n\t\t\t\t\t\tprojectKey: ctx.repo.get(\"repo\").key,\n\t\t\t\t\t});\n\t\t\t\tlet published: { headSha: string };\n\t\t\t\ttry {\n\t\t\t\t\tpublished =\n\t\t\t\t\t\tadjustment.origin === \"rebase\"\n\t\t\t\t\t\t\t? publishRebase(rebaseInput(ctx))\n\t\t\t\t\t\t\t: await commitWorkBranch(\n\t\t\t\t\t\t\t\t\t{ ...ctx, state: patchRemote(ctx.state, current) },\n\t\t\t\t\t\t\t\t\tadapter.commitMessage(adjustment.origin),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof ConcurrentRebaseSourceError) {\n\t\t\t\t\t\tif (error.published) return reconcileAgain();\n\t\t\t\t\t\tconst project = ctx.repo.get(\"repo\");\n\t\t\t\t\t\tretainConcurrentRebase({\n\t\t\t\t\t\t\tprojectKey: project.key,\n\t\t\t\t\t\t\trepoPath: project.fsPath,\n\t\t\t\t\t\t\tworkBranch: project.workBranch,\n\t\t\t\t\t\t\tbaselineSha: error.repair.originalHead,\n\t\t\t\t\t\t\trebasedHead: error.repair.headSha,\n\t\t\t\t\t\t\ttargetBase: error.repair.baseSha,\n\t\t\t\t\t\t\tgitIdentity: await adapter.identity(ctx),\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn reconcileAgain();\n\t\t\t\t\t}\n\t\t\t\t\tif (!(error instanceof RemoteBranchChangedError)) throw error;\n\t\t\t\t\treturn reconcileAgain();\n\t\t\t\t}\n\t\t\t\tif (adjustment.origin === \"rebase\") {\n\t\t\t\t\tconst head = await adapter.head(ctx, current);\n\t\t\t\t\tif (head !== published.headSha)\n\t\t\t\t\t\tthrow new Error(\"Pull request head has not caught up with rebase publication\");\n\t\t\t\t}\n\t\t\t\tadjustmentPublished = published.headSha !== publicationLease;\n\t\t\t\tacknowledgePublication(published.headSha, adjustmentPublished);\n\t\t\t}\n\t\t\tif (adjustment.origin === \"rebase\") await adapter.afterRebase(ctx, current);\n\t\t\tif (adjustment.origin === \"feedback\" && !adapter.maintenance) {\n\t\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"reply_feedback\"));\n\t\t\t\tawait adapter.reply(ctx, current);\n\t\t\t}\n\t\t\tupdate({\n\t\t\t\t...(adjustment.origin === \"feedback\" && !adapter.maintenance ? { feedbackIds: [] } : {}),\n\t\t\t\t...(adjustment.origin === \"rebase\" ? { conflict: null } : {}),\n\t\t\t\tdelivery: {\n\t\t\t\t\tadjustment: null,\n\t\t\t\t\t...(adjustment.origin === \"feedback\" && adapter.maintenance\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tfeedbackResult: {\n\t\t\t\t\t\t\t\t\tpublished: adjustmentPublished,\n\t\t\t\t\t\t\t\t\tsummary: adjustmentPublished\n\t\t\t\t\t\t\t\t\t\t? \"Review adjustment published\"\n\t\t\t\t\t\t\t\t\t\t: (adjustment.summary ?? \"No repository change was required\"),\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},\n\t\t\t});\n\t\t}\n\n\t\tif (current.feedbackIds.length > 0 && !adapter.maintenance) {\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"reply_feedback\"));\n\t\t\tawait adapter.acknowledge(ctx, current);\n\t\t\treturn result(\"feedback_ready\");\n\t\t}\n\n\t\tupdate({ delivery: { stage: \"awaiting\" } });\n\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"await_evidence\"));\n\t\treturn result(\"awaiting\");\n\t};\n\tconst delivery = flow\n\t\t.automatic<P, RepositoryChangeState>(ids.deliver)\n\t\t.description(\"Deliver\")\n\t\t.waitFor(({ state, params }) => {\n\t\t\tconst states = adapter.repositories\n\t\t\t\t? adapter.repositories(params).map(({ key }) => select(state, key))\n\t\t\t\t: [state];\n\t\t\treturn states.some((state) => {\n\t\t\t\tconst current = remote(state);\n\t\t\t\tif (adapter.maintenance)\n\t\t\t\t\treturn (\n\t\t\t\t\t\t!current.stopped &&\n\t\t\t\t\t\t!current.noChanges &&\n\t\t\t\t\t\t!current.delivery.terminalPullRequest &&\n\t\t\t\t\t\t(current.delivery.stage !== \"awaiting\" || !!current.delivery.adjustment)\n\t\t\t\t\t);\n\t\t\t\treturn (\n\t\t\t\t\tcurrent.delivery.stage !== \"awaiting\" ||\n\t\t\t\t\t!!current.pendingEvidence ||\n\t\t\t\t\t!!current.delivery.adjustment ||\n\t\t\t\t\tcurrent.feedbackIds.length > 0 ||\n\t\t\t\t\t!!current.delivery.terminalPullRequest\n\t\t\t\t);\n\t\t\t});\n\t\t})\n\t\t.integrationTools(...adapter.tools.delivery)\n\t\t.run(async (ctx) => {\n\t\t\tif (!adapter.repositories) return runRepository(ctx);\n\t\t\tlet state = ctx.state;\n\t\t\tconst repositories = adapter.repositories(ctx.params);\n\t\t\tif (!repositories.length) throw new Error(\"No repositories are bound\");\n\t\t\tconst results = () =>\n\t\t\t\trepositories.map(({ key }) => ({ key, current: remote(select(state, key)) }));\n\t\t\tconst finished = () => results().every(({ current }) => publicationFinished(current));\n\t\t\t// Terminal facts take precedence over cancellation, including after interrupted publication.\n\t\t\tconst reconcileTerminals = async () => {\n\t\t\t\tfor (const { key } of repositories) {\n\t\t\t\t\tstate = select(state, key);\n\t\t\t\t\tconst current = remote(state);\n\t\t\t\t\tif (publicationFinished(current)) continue;\n\t\t\t\t\tconst terminal = await adapter.observeTerminal?.(\n\t\t\t\t\t\trepositoryContext({ ...ctx, state }),\n\t\t\t\t\t\tcurrent,\n\t\t\t\t\t);\n\t\t\t\t\tif (terminal)\n\t\t\t\t\t\tstate = patchRemote(state, {\n\t\t\t\t\t\t\tprNumber: terminal.number,\n\t\t\t\t\t\t\tprUrl: terminal.html_url,\n\t\t\t\t\t\t\tdelivery: { terminalPullRequest: terminal },\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\t\t\tawait reconcileTerminals();\n\t\t\tlet cancelled = false;\n\t\t\tfor (const { key } of repositories) {\n\t\t\t\tstate = select(state, key);\n\t\t\t\tif (publicationFinished(remote(state))) continue;\n\t\t\t\tif (await adapter.sourceCancelled?.({ ...ctx, state })) {\n\t\t\t\t\tawait reconcileTerminals();\n\t\t\t\t\tcancelled = !finished();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconst result = await runRepository(repositoryContext({ ...ctx, state }));\n\t\t\t\tstate = result.params.nextState;\n\t\t\t\tif (![\"awaiting\", \"completed\", \"aborted\"].includes(result.outcome))\n\t\t\t\t\treturn { ...result, params: { nextState: state } };\n\t\t\t}\n\t\t\tif (cancelled || finished()) {\n\t\t\t\tawait adapter.reconcileAll?.({ ...ctx, state }, results(), cancelled);\n\t\t\t\tconst requests = results().flatMap(({ current }) =>\n\t\t\t\t\tcurrent.delivery.terminalPullRequest ? [current.delivery.terminalPullRequest] : [],\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\toutcome:\n\t\t\t\t\t\tcancelled || (requests.length > 0 && requests.every((request) => !request.merged))\n\t\t\t\t\t\t\t? \"aborted\"\n\t\t\t\t\t\t\t: \"completed\",\n\t\t\t\t\tparams: { nextState: state },\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn { outcome: \"awaiting\", params: { nextState: state } };\n\t\t});\n\tconst outcome = (o: AutomaticOutcomeBuilder<P, RepositoryChangeState>, description: string) =>\n\t\to\n\t\t\t.description(description)\n\t\t\t.object(\"nextState\")\n\t\t\t.state(({ event }) => event.params.nextState as RepositoryChangeState);\n\tdelivery\n\t\t.outcome(\"awaiting\", (o) => outcome(o, \"Delivery is waiting for external evidence\").wait())\n\t\t.outcome(\"completed\", (o) => outcome(o, \"Merged pull request was reconciled\").complete())\n\t\t.outcome(\"aborted\", (o) =>\n\t\t\toutcome(o, \"Closed pull request was reconciled\").lifecycleStatus(\"aborted\"),\n\t\t);\n\tif (!adapter.maintenance)\n\t\tdelivery.outcome(\"feedback_ready\", (o) =>\n\t\t\toutcome(o, \"Pull request feedback is acknowledged and ready for revision\").to(ids.feedback),\n\t\t);\n\tfor (const [name, target] of [\n\t\t[\"ci_ready\", ids.ciRepair],\n\t\t[\"conflict_ready\", ids.feedback],\n\t\t[\"operator_action\", ids.operator],\n\t] as const) {\n\t\tdelivery.outcome(name, (o) => outcome(o, \"Route observed delivery evidence\").to(target));\n\t}\n\tfor (const source of adapter.sources) {\n\t\tif (adapter.maintenance && source.kind === \"observation\") continue;\n\t\tconst attach = (id: string, operator: boolean) =>\n\t\t\tdelivery.externalAction(id, source.source, (external) => {\n\t\t\t\texternal\n\t\t\t\t\t.label(source.label)\n\t\t\t\t\t.when(\n\t\t\t\t\t\t({ params, state }) =>\n\t\t\t\t\t\t\t(!source.enabled || source.enabled(params, state)) &&\n\t\t\t\t\t\t\t(source.kind === \"cancelled\" ||\n\t\t\t\t\t\t\t\t(adapter.repositories\n\t\t\t\t\t\t\t\t\t? adapter.repositories(params).map(({ key }) => remote(select(state, key)))\n\t\t\t\t\t\t\t\t\t: [remote(state)]\n\t\t\t\t\t\t\t\t).every(\n\t\t\t\t\t\t\t\t\t(current) =>\n\t\t\t\t\t\t\t\t\t\tcurrent.noChanges ||\n\t\t\t\t\t\t\t\t\t\tcurrent.delivery.terminalPullRequest ||\n\t\t\t\t\t\t\t\t\t\t!!(current.headSha && current.prNumber && current.prUrl),\n\t\t\t\t\t\t\t\t)) &&\n\t\t\t\t\t\t\t(source.kind !== \"failure\" || remote(state).ciRecoveryCycles >= 3 === operator),\n\t\t\t\t\t);\n\t\t\t\tif (source.kind === \"cancelled\") return external.lifecycleStatus(\"aborted\");\n\t\t\t\texternal.to(\n\t\t\t\t\tsource.kind === \"conflict\"\n\t\t\t\t\t\t? ids.feedback\n\t\t\t\t\t\t: source.kind === \"failure\"\n\t\t\t\t\t\t\t? operator\n\t\t\t\t\t\t\t\t? ids.operator\n\t\t\t\t\t\t\t\t: ids.ciRepair\n\t\t\t\t\t\t\t: ids.deliver,\n\t\t\t\t);\n\t\t\t\treturn external.effect((input) => {\n\t\t\t\t\tconst evidence = source.read(input);\n\t\t\t\t\tconst state =\n\t\t\t\t\t\tadapter.repositories && evidence.projectKey\n\t\t\t\t\t\t\t? select(input.state, evidence.projectKey)\n\t\t\t\t\t\t\t: input.state;\n\t\t\t\t\tconst current = remote(state);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstate: patchRemote(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tsource.kind === \"observation\"\n\t\t\t\t\t\t\t\t? { pendingEvidence: evidence }\n\t\t\t\t\t\t\t\t: applyPublicationEvidence(input.params, current, evidence, !operator),\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t});\n\t\tattach(source.id, false);\n\t\tif (source.kind === \"failure\") attach(source.operatorId ?? `${source.id}_operator`, true);\n\t}\n\tif (adapter.maintenance) {\n\t\tfor (const [id, target] of [\n\t\t\t[\"feedback\", ids.feedback],\n\t\t\t[\"conflict\", ids.feedback],\n\t\t\t[\"ci\", ids.ciRepair],\n\t\t\t[\"operator\", ids.operator],\n\t\t] as const)\n\t\t\tdelivery.externalAction(`maintenance_${id}`, adapter.maintenance.source, (action) =>\n\t\t\t\taction\n\t\t\t\t\t.label(\"Maintain MR\")\n\t\t\t\t\t.to(target)\n\t\t\t\t\t.effect(({ event }) => ({ state: event.state })),\n\t\t\t);\n\t}\n\tpublication.turn(delivery);\n\tfunction rebaseInput(ctx: {\n\t\tstate: RepositoryChangeState;\n\t\trepo: { get(key: string): { fsPath: string; workBranch: string } };\n\t}) {\n\t\tconst project = ctx.repo.get(activeKey(ctx.state) ?? \"repo\");\n\t\tconst conflict = remote(ctx.state).conflict;\n\t\tif (!conflict) throw new Error(\"Missing conflict evidence\");\n\t\treturn {\n\t\t\tprojectKey: activeKey(ctx.state) ?? \"repo\",\n\t\t\tpath: project.fsPath,\n\t\t\tworkBranch: project.workBranch,\n\t\t\tconflict,\n\t\t};\n\t}\n\tfunction repairReason(state: RepositoryChangeState, kind: \"feedback\" | \"ci\") {\n\t\treturn kind === \"feedback\" && remote(state).repairReason === \"rebase\" ? \"rebase\" : kind;\n\t}\n\n\tfunction revisionTurn(id: string, kind: \"feedback\" | \"ci\") {\n\t\tconst turn = flow\n\t\t\t.llm<P, RepositoryChangeState>(id)\n\t\t\t.description(kind === \"feedback\" ? \"Address Feedback\" : \"Fix CI\")\n\t\t\t.waitFor(({ state }) => {\n\t\t\t\tconst current = remote(state);\n\t\t\t\treturn (\n\t\t\t\t\t!current.stopped &&\n\t\t\t\t\t!current.delivery.terminalPullRequest &&\n\t\t\t\t\t(kind === \"feedback\"\n\t\t\t\t\t\t? current.feedbackIds.length > 0 ||\n\t\t\t\t\t\t\t!!current.conflict ||\n\t\t\t\t\t\t\t!!current.reconciliationRequired\n\t\t\t\t\t\t: current.repairReason === \"ci\" && current.pipeline !== null)\n\t\t\t\t);\n\t\t\t})\n\t\t\t.executionPurpose(codingPurposes.implementation)\n\t\t\t.tools(\"read\", \"bash\", \"edit\", \"write\")\n\t\t\t.resolveIntegrationTools((_params, state) =>\n\t\t\t\trepairReason(state, kind) === \"rebase\" && !remote(state).reconciliationRequired\n\t\t\t\t\t? []\n\t\t\t\t\t: adapter.tools[kind],\n\t\t\t)\n\t\t\t.prepare(async (ctx) => {\n\t\t\t\tconst project = ctx.repo.get(activeKey(ctx.state) ?? \"repo\");\n\t\t\t\tconst current = remote(ctx.state);\n\t\t\t\tconst prepareDependencies = () =>\n\t\t\t\t\tadapter.prepareSubmodules ? prepareSubmodules(project, ctx) : undefined;\n\t\t\t\tconst prepareRebase = async () => {\n\t\t\t\t\tstartRebase(rebaseInput(ctx));\n\t\t\t\t\treturn { deferredRebase: false, submoduleWarning: await prepareDependencies() };\n\t\t\t\t};\n\t\t\t\tconst targetRebase =\n\t\t\t\t\trepairReason(ctx.state, kind) === \"rebase\" && !current.reconciliationRequired;\n\t\t\t\t// Resume Git's existing target repair; it must not be mistaken for source synchronization.\n\t\t\t\tif (targetRebase && hasPreparedRebase(rebaseInput(ctx))) return prepareRebase();\n\t\t\t\tconst report = (label: string, status: \"in_progress\" | \"completed\") =>\n\t\t\t\t\tctx.reportProgress({\n\t\t\t\t\t\ttitle: \"Repository reconciliation\",\n\t\t\t\t\t\tsteps: [{ id: \"reconcile_source\", label, status }],\n\t\t\t\t\t});\n\t\t\t\treport(\"Reconcile remote changes and retained local work\", \"in_progress\");\n\t\t\t\tconst reconciliation = await reconcile(repositoryContext(ctx), current);\n\t\t\t\tif (reconciliation.status === \"conflicts\")\n\t\t\t\t\treport(\"Resolve reconciliation conflicts\", \"in_progress\");\n\t\t\t\telse report(\"Repository reconciled\", \"completed\");\n\t\t\t\tif (\n\t\t\t\t\ttargetRebase &&\n\t\t\t\t\treconciliation.status === \"unchanged\" &&\n\t\t\t\t\treconciliation.headSha === current.conflict?.headSha &&\n\t\t\t\t\t!repositoryWorktreeIsDirty({ projectKey: project.key, repoPath: project.fsPath })\n\t\t\t\t)\n\t\t\t\t\treturn prepareRebase();\n\t\t\t\treturn {\n\t\t\t\t\tdeferredRebase: targetRebase,\n\t\t\t\t\tsubmoduleWarning:\n\t\t\t\t\t\treconciliation.status !== \"conflicts\" ? await prepareDependencies() : undefined,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.freshPrimary()\n\t\t\t.buildPrompt((ctx) => {\n\t\t\t\tconst current = remote(ctx.state);\n\t\t\t\tconst repository = adapter.repositories\n\t\t\t\t\t? `Repository: ${activeKey(ctx.state)}. Apply changes only to this checkout. `\n\t\t\t\t\t: \"\";\n\t\t\t\tlet prompt: string;\n\t\t\t\tif (ctx.prepared?.deferredRebase)\n\t\t\t\t\tprompt = `${repository}${reconciliationPrompt}\\nThe source branch or retained local work must be reconciled before the target-branch repair. Resolve any source reconciliation, then use changes_ready. Delivery will restore and validate the result before reassessing current target conflicts.`;\n\t\t\t\telse if (current.reconciliationRequired)\n\t\t\t\t\tprompt = `${repository}${reconciliationPrompt}\\nValidate the reconciled repository, including any upstream target changes and retained local work, against the requested change and pending feedback: ${JSON.stringify(current.feedbackIds)}. Treat the current remote as authoritative; do not restore deliberately removed code simply to match an older plan. Use changes_ready after validation, even when no further edit is needed, so retained local changes are published. If blocked use cannot_repair.\\nOriginal request for context: ${ctx.prompts.initial || \"Inspect the current repository and retained request\"}`;\n\t\t\t\telse if (repairReason(ctx.state, kind) === \"rebase\")\n\t\t\t\t\tprompt = `${rebasePrompt} Evidence: ${JSON.stringify(current.conflict)}. Call changes_ready or no_changes when verified complete, cannot_repair when blocked.`;\n\t\t\t\telse prompt = `${repository}${adapter.prompt(kind, current)}\\n\\n${reconciliationPrompt}`;\n\t\t\t\treturn [prompt, ctx.prepared?.submoduleWarning].filter(Boolean).join(\"\\n\\n\");\n\t\t\t});\n\t\tfor (const [name, description] of [\n\t\t\t[\"changes_ready\", \"Repository changes are ready to publish\"],\n\t\t\t[\"no_changes\", \"No repository change is required\"],\n\t\t] as const) {\n\t\t\tturn.outcomeTool(name, (tool) =>\n\t\t\t\ttool\n\t\t\t\t\t.resultSummary()\n\t\t\t\t\t.description(description)\n\t\t\t\t\t.to(ids.deliver)\n\t\t\t\t\t.state(({ ctx, event }) =>\n\t\t\t\t\t\tpatchRemote(ctx.state, {\n\t\t\t\t\t\t\trepairPending: false,\n\t\t\t\t\t\t\tdelivery: {\n\t\t\t\t\t\t\t\t// Even no_changes must cross delivery's remote race check. It may\n\t\t\t\t\t\t\t\t// have inherited unpublished work or a concurrent developer push.\n\t\t\t\t\t\t\t\tadjustment: {\n\t\t\t\t\t\t\t\t\torigin: remote(ctx.state).reconciliationRequired\n\t\t\t\t\t\t\t\t\t\t? \"feedback\"\n\t\t\t\t\t\t\t\t\t\t: repairReason(ctx.state, kind),\n\t\t\t\t\t\t\t\t\tpublishRequired:\n\t\t\t\t\t\t\t\t\t\tname === \"changes_ready\" || !!remote(ctx.state).reconciliationRequired,\n\t\t\t\t\t\t\t\t\tsummary: String(\n\t\t\t\t\t\t\t\t\t\tevent.params?.resultSummary ?? \"No repository change was required\",\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}),\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn turn.outcomeTool(\"cannot_repair\", (tool) => {\n\t\t\tconst outcome = tool.description(\"The adjustment requires operator action\").to(ids.operator);\n\t\t\treturn adapter.maintenance\n\t\t\t\t? outcome.state(({ ctx }) => patchRemote(ctx.state, { repairPending: false }))\n\t\t\t\t: outcome;\n\t\t});\n\t}\n\n\tpublication.turn(revisionTurn(ids.feedback, \"feedback\"));\n\tpublication.turn(revisionTurn(ids.ciRepair, \"ci\"));\n\tconst maintenanceSource = adapter.maintenance?.source;\n\tpublication.turn({\n\t\tid: ids.operator,\n\t\tdefinition: {\n\t\t\tkind: \"human\",\n\t\t\tdescription: \"Repository repair needs operator action\",\n\t\t\toperatorAttention: \"required\",\n\t\t\t...(maintenanceSource\n\t\t\t\t? {\n\t\t\t\t\t\texternalActions: Object.fromEntries(\n\t\t\t\t\t\t\t([\"feedback\", \"conflict\"] as const).map((id) => [\n\t\t\t\t\t\t\t\t`maintenance_${id}`,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: `maintenance_${id}`,\n\t\t\t\t\t\t\t\t\tsource: maintenanceSource,\n\t\t\t\t\t\t\t\t\tto: ids.feedback,\n\t\t\t\t\t\t\t\t\tlabel: \"Maintain MR\",\n\t\t\t\t\t\t\t\t\teffect: ({ event }: { event: unknown }) => ({\n\t\t\t\t\t\t\t\t\t\tstate: (event as { state: RepositoryChangeState }).state,\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),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\tactions: {\n\t\t\t\tretry_repair: {\n\t\t\t\t\tlabel: \"Retry repair\",\n\t\t\t\t\tacceptanceState: \"accepted\",\n\t\t\t\t\tbranches: { feedback: { to: ids.feedback }, ci: { to: ids.ciRepair } },\n\t\t\t\t\teffect: adapter.maintenance\n\t\t\t\t\t\t? ({ ctx }) => ({ state: patchRemote(ctx.state, { reconciliationCycles: 0 }) })\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tchoose: ({ ctx }) =>\n\t\t\t\t\t\tremote(ctx.state).repairReason === \"rebase\" ||\n\t\t\t\t\t\tremote(ctx.state).repairReason === \"feedback\" ||\n\t\t\t\t\t\tremote(ctx.state).reconciliationRequired\n\t\t\t\t\t\t\t? \"feedback\"\n\t\t\t\t\t\t\t: \"ci\",\n\t\t\t\t},\n\t\t\t\tresume_waiting: {\n\t\t\t\t\tlabel: \"Resume waiting\",\n\t\t\t\t\tacceptanceState: \"accepted\",\n\t\t\t\t\tto: ids.deliver,\n\t\t\t\t\teffect: ({ ctx }) => ({\n\t\t\t\t\t\tstate: patchRemote(ctx.state, {\n\t\t\t\t\t\t\trepairPending: false,\n\t\t\t\t\t\t\tfeedbackIds: [],\n\t\t\t\t\t\t\tdelivery: { adjustment: null },\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\tabort: { label: \"Abort process\", acceptanceState: \"neutral\", lifecycleStatus: \"aborted\" },\n\t\t\t},\n\t\t},\n\t});\n\n\treturn {\n\t\t/** @public */\n\t\tentryTurnId: ids.deliver,\n\n\t\t/** @public */\n\t\tfragment: publication,\n\n\t\t/** @public */\n\t\thappyPath: [ids.deliver],\n\t\t/** @internal */\n\t\tprepareSubmodules: adapter.prepareSubmodules,\n\t};\n}\n","import { execFileSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { repositoryGitArgs, repositoryGitSubprocessEnv } from \"@leitwerk-dev/process-sdk\";\nimport { resolveGitBinary } from \"@leitwerk-dev/process-sdk/git-binary\";\nimport {\n\tpushWasRejected,\n\ttype RepositoryPublicationReceipt,\n\treadPublicationReceipt,\n\treadRepositoryBinding,\n\trepositoryBindingMatches,\n\tsavePublicationReceipt,\n} from \"../repository-publication-receipt.js\";\nimport { assertReconciliationTargetSafe } from \"../repository-reconciliation.js\";\nimport { repositoryRecord } from \"../repository-record.js\";\n\nimport { type ConflictEvidence, conflictKey } from \"./index.js\";\nimport {\n\ttype RebaseRecord,\n\trequireRebaseHead,\n\trequireRebaseOrigin,\n\trequireRebaseTarget,\n\trequireRebaseWorktree,\n} from \"./policy.js\";\n\n/** @internal */\nexport interface RebaseInput {\n\t/** @internal */\n\tprojectKey: string;\n\t/** @internal */\n\tpath: string;\n\t/** @internal */\n\tworkBranch: string;\n\t/** @internal */\n\tconflict: ConflictEvidence;\n}\nfunction git(input: RebaseInput, ...args: string[]): string {\n\treturn execFileSync(resolveGitBinary(), repositoryGitArgs(args), {\n\t\tcwd: input.path,\n\t\tencoding: \"utf8\",\n\t\tenv: repositoryGitSubprocessEnv(input.projectKey, {\n\t\t\tGIT_TERMINAL_PROMPT: \"0\",\n\t\t\tGIT_EDITOR: \"true\",\n\t\t}),\n\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t}).trim();\n}\nfunction area(input: RebaseInput): string {\n\treturn git(input, \"rev-parse\", \"--absolute-git-dir\");\n}\nfunction active(gitDir: string): boolean {\n\treturn [\"rebase-merge\", \"rebase-apply\"].some((name) => existsSync(join(gitDir, name)));\n}\nconst recordFile = (gitDir: string) => repositoryRecord<RebaseRecord>(gitDir, \"rebase\");\nfunction requireWorktree(input: RebaseInput): void {\n\trequireRebaseWorktree(input.workBranch, {\n\t\tbranch: git(input, \"branch\", \"--show-current\"),\n\t\tdirty: Boolean(git(input, \"status\", \"--porcelain\")),\n\t});\n}\nfunction remoteHead(input: RebaseInput): string {\n\treturn git(input, \"ls-remote\", \"--heads\", \"origin\", `refs/heads/${input.workBranch}`).split(\n\t\t/\\s+/,\n\t)[0];\n}\n\nfunction requireTarget(input: RebaseInput, record?: RebaseRecord | null): void {\n\trequireRebaseTarget(input.workBranch, input.conflict, record);\n\tgit(input, \"check-ref-format\", `refs/heads/${input.workBranch}`);\n\tgit(input, \"check-ref-format\", `refs/heads/${input.conflict.baseBranch}`);\n\trequireRebaseOrigin(record, {\n\t\toriginUrl: record?.originUrl ? git(input, \"remote\", \"get-url\", \"origin\") : undefined,\n\t\toriginPushUrl: record?.originPushUrl\n\t\t\t? git(input, \"remote\", \"get-url\", \"--push\", \"--all\", \"origin\")\n\t\t\t: undefined,\n\t});\n}\n\nfunction verifyCurrentBase(input: RebaseInput, record: RebaseRecord): void {\n\tgit(\n\t\tinput,\n\t\t\"fetch\",\n\t\t\"origin\",\n\t\t`+refs/heads/${input.conflict.baseBranch}:refs/leitwerk/rebase-base`,\n\t);\n\t// A fast-forward is compatible with captured preparation; a rewritten base is not.\n\tgit(input, \"merge-base\", \"--is-ancestor\", record.baseSha, \"refs/leitwerk/rebase-base\");\n}\n\nfunction verifyNoRepairNeeded(input: RebaseInput, headSha: string, baseSha: string): void {\n\tif (input.conflict.reason === \"behind\")\n\t\tgit(input, \"merge-base\", \"--is-ancestor\", baseSha, headSha);\n\telse git(input, \"merge-tree\", \"--write-tree\", headSha, baseSha);\n}\n\n/** @internal */\nexport function hasPreparedRebase(input: RebaseInput): boolean {\n\treturn recordFile(area(input)).read()?.key === conflictKey(input.conflict);\n}\n\n/** Persist the lease before changing HEAD; a retry resumes Git's own rebase state. @internal */\nexport function prepareRebase(input: RebaseInput): RebaseRecord {\n\tconst gitDir = area(input);\n\tconst old = recordFile(gitDir).read();\n\trequireTarget(input, old?.key === conflictKey(input.conflict) ? old : null);\n\tif (old?.key === conflictKey(input.conflict)) {\n\t\tverifyCurrentBase(input, old);\n\t\treturn old;\n\t}\n\tif (active(gitDir)) throw new Error(\"An unrelated rebase is already in progress\");\n\trequireWorktree(input);\n\tgit(\n\t\tinput,\n\t\t\"fetch\",\n\t\t\"origin\",\n\t\t`+refs/heads/${input.workBranch}:refs/leitwerk/rebase-head`,\n\t\t`+refs/heads/${input.conflict.baseBranch}:refs/leitwerk/rebase-base`,\n\t);\n\tconst [remoteSha, headSha, baseSha] = git(\n\t\tinput,\n\t\t\"rev-parse\",\n\t\t\"refs/leitwerk/rebase-head\",\n\t\t\"HEAD\",\n\t\t\"refs/leitwerk/rebase-base\",\n\t).split(\"\\n\");\n\trequireRebaseHead(input.conflict.headSha, headSha, remoteSha);\n\t// Use the current fetched base, retaining the provider pair for deduplication.\n\tgit(input, \"merge-base\", \"--is-ancestor\", input.conflict.baseSha, baseSha);\n\tconst record: RebaseRecord = {\n\t\tkey: conflictKey(input.conflict),\n\t\tbranch: input.workBranch,\n\t\toriginalHead: input.conflict.headSha,\n\t\tbaseSha,\n\t\tstatus: \"prepared\",\n\t\toriginUrl: git(input, \"remote\", \"get-url\", \"origin\"),\n\t\toriginPushUrl: git(input, \"remote\", \"get-url\", \"--push\", \"--all\", \"origin\"),\n\t\tbaseBranch: input.conflict.baseBranch,\n\t};\n\tgit(input, \"update-ref\", \"refs/leitwerk/rebase-original\", record.originalHead);\n\trecordFile(gitDir).save(record);\n\treturn record;\n}\n/** @internal */\nexport function startRebase(input: RebaseInput): RebaseRecord {\n\tconst record = prepareRebase(input);\n\tconst gitDir = area(input);\n\tif (active(gitDir)) return record;\n\tif (record.status === \"clean\") return record;\n\trequireWorktree(input);\n\tif (record.status === \"rebasing\" && git(input, \"rev-parse\", \"HEAD\") !== record.originalHead)\n\t\treturn record;\n\ttry {\n\t\tverifyNoRepairNeeded(input, record.originalHead, record.baseSha);\n\t\trecord.status = \"clean\";\n\t\trecordFile(gitDir).save(record);\n\t\treturn record;\n\t} catch (error) {\n\t\tif ((error as { status?: number }).status !== 1) throw error;\n\t}\n\tassertReconciliationTargetSafe(\n\t\t{ projectKey: input.projectKey, repoPath: input.path },\n\t\trecord.baseSha,\n\t);\n\trecord.status = \"rebasing\";\n\trecordFile(gitDir).save(record);\n\ttry {\n\t\tgit(input, \"rebase\", \"--rebase-merges\", record.baseSha);\n\t} catch (error) {\n\t\tif (!active(gitDir)) throw error;\n\t}\n\treturn record;\n}\n/** @internal */\nexport function verifyRebase(input: RebaseInput): {\n\t/** @internal */\n\theadSha: string;\n\t/** @internal */\n\tchanged: boolean;\n\t/** @internal */\n\toriginalHead: string;\n\t/** @internal */\n\tbaseSha: string;\n} {\n\tconst gitDir = area(input);\n\tconst record = recordFile(gitDir).read();\n\tif (!record || record.key !== conflictKey(input.conflict))\n\t\tthrow new Error(\"Missing matching rebase metadata\");\n\trequireTarget(input, record);\n\tif (active(gitDir)) throw new Error(\"Rebase is incomplete\");\n\trequireWorktree(input);\n\tconst headSha = git(input, \"rev-parse\", \"HEAD\");\n\tif (record.status === \"clean\") {\n\t\tif (headSha !== record.originalHead)\n\t\t\tthrow new Error(\"Clean conflict report must not rewrite the branch\");\n\t\tverifyNoRepairNeeded(input, headSha, record.baseSha);\n\t} else {\n\t\tif (record.status !== \"rebasing\") throw new Error(\"Rebase was not started\");\n\t\tgit(input, \"merge-base\", \"--is-ancestor\", record.baseSha, headSha);\n\t}\n\treturn {\n\t\theadSha,\n\t\tchanged: headSha !== record.originalHead,\n\t\toriginalHead: record.originalHead,\n\t\tbaseSha: record.baseSha,\n\t};\n}\n/** @internal */\nexport class ConcurrentRebaseSourceError extends Error {\n\tconstructor(\n\t\treadonly repair: ReturnType<typeof verifyRebase>,\n\t\treadonly published = false,\n\t) {\n\t\tsuper(\"Concurrent remote change rejected by rebase lease; local repair was retained\");\n\t}\n}\n\n/** @internal */\nexport function publishRebase(input: RebaseInput): ReturnType<typeof verifyRebase> {\n\tconst result = verifyRebase(input);\n\tassertReconciliationTargetSafe(\n\t\t{ projectKey: input.projectKey, repoPath: input.path },\n\t\tresult.baseSha,\n\t);\n\tconst gitDir = area(input);\n\tconst record = recordFile(gitDir).read();\n\tif (!record) throw new Error(\"Missing matching rebase metadata\");\n\tverifyCurrentBase(input, record);\n\tconst remote = remoteHead(input);\n\tconst binding = readRepositoryBinding((...args) => git(input, ...args), input.workBranch);\n\tif (binding.origin !== binding.pushOrigin)\n\t\tthrow new Error(\"Fetch and push endpoints must match for publication\");\n\tconst previous = readPublicationReceipt(gitDir);\n\tif (!repositoryBindingMatches(previous, binding))\n\t\tthrow new Error(\"Repository publication receipt binding changed\");\n\tconst receipt: RepositoryPublicationReceipt = {\n\t\t...binding,\n\t\texpectedHead: result.originalHead,\n\t\tcandidate: result.headSha,\n\t\tstatus: \"attempting\",\n\t};\n\tif (remote === result.headSha) {\n\t\tsavePublicationReceipt(gitDir, { ...receipt, status: \"accepted\" });\n\t\treturn result;\n\t}\n\tif (previous?.candidate === result.headSha && previous.status === \"accepted\")\n\t\tthrow new ConcurrentRebaseSourceError(result, true);\n\tif (previous?.status === \"attempting\") {\n\t\tgit(\n\t\t\tinput,\n\t\t\t\"fetch\",\n\t\t\t\"--no-tags\",\n\t\t\t\"origin\",\n\t\t\t`+refs/heads/${input.workBranch}:refs/leitwerk/rebase-publication-proof`,\n\t\t);\n\t\ttry {\n\t\t\tgit(\n\t\t\t\tinput,\n\t\t\t\t\"merge-base\",\n\t\t\t\t\"--is-ancestor\",\n\t\t\t\tprevious.candidate,\n\t\t\t\t\"refs/leitwerk/rebase-publication-proof\",\n\t\t\t);\n\t\t} catch {\n\t\t\tthrow new Error(\n\t\t\t\t\"Prior target publication outcome is uncertain; local repair was retained for operator reconciliation\",\n\t\t\t);\n\t\t}\n\t\tsavePublicationReceipt(gitDir, { ...previous, status: \"accepted\" });\n\t\tthrow new ConcurrentRebaseSourceError(result, previous.candidate === result.headSha);\n\t}\n\tif (remote !== result.originalHead) throw new ConcurrentRebaseSourceError(result);\n\tsavePublicationReceipt(gitDir, receipt);\n\ttry {\n\t\tgit(\n\t\t\tinput,\n\t\t\t\"push\",\n\t\t\t\"--porcelain\",\n\t\t\t\"--no-follow-tags\",\n\t\t\t\"--recurse-submodules=no\",\n\t\t\t`--force-with-lease=refs/heads/${input.workBranch}:${result.originalHead}`,\n\t\t\t\"origin\",\n\t\t\t`${result.headSha}:refs/heads/${input.workBranch}`,\n\t\t);\n\t} catch (error) {\n\t\tconst rejected = pushWasRejected((error as { stdout?: Buffer }).stdout?.toString() ?? \"\");\n\t\tif (rejected) savePublicationReceipt(gitDir, { ...receipt, status: \"rejected\" });\n\t\tconst latest = remoteHead(input);\n\t\tif (latest === result.headSha) {\n\t\t\tsavePublicationReceipt(gitDir, { ...receipt, status: \"accepted\" });\n\t\t\treturn result;\n\t\t}\n\t\tif (rejected && latest !== result.originalHead) throw new ConcurrentRebaseSourceError(result);\n\t\tthrow error;\n\t}\n\tsavePublicationReceipt(gitDir, { ...receipt, status: \"accepted\" });\n\tif (remoteHead(input) !== result.headSha) throw new ConcurrentRebaseSourceError(result, true);\n\treturn result;\n}\n","import type { ConflictEvidence } from \"./index.js\";\n\n/** Durable preparation evidence; optional identity fields support older records. @internal */\nexport interface RebaseRecord {\n\t/** @internal */\n\tkey: string;\n\t/** @internal */\n\tbranch: string;\n\t/** @internal */\n\toriginalHead: string;\n\t/** @internal */\n\tbaseSha: string;\n\t/** @internal */\n\tstatus: \"prepared\" | \"rebasing\" | \"clean\";\n\t/** @internal */\n\toriginUrl?: string;\n\t/** @internal */\n\toriginPushUrl?: string;\n\t/** @internal */\n\tbaseBranch?: string;\n}\n\n/** Validate provider evidence against the tracked branch and retained preparation. @internal */\nexport function requireRebaseTarget(\n\tworkBranch: string,\n\tconflict: ConflictEvidence,\n\trecord?: RebaseRecord | null,\n): void {\n\tif (workBranch !== conflict.headBranch || workBranch === conflict.baseBranch)\n\t\tthrow new Error(\"Expected evidence for the tracked work branch and a distinct base\");\n\tif (record && (record.branch !== workBranch || record.originalHead !== conflict.headSha))\n\t\tthrow new Error(\"Missing matching rebase metadata\");\n\tif (record?.baseBranch && record.baseBranch !== conflict.baseBranch)\n\t\tthrow new Error(\"Rebase base branch changed since preparation\");\n}\n\n/** Compare observed remote identity only where preparation retained it. @internal */\nexport function requireRebaseOrigin(\n\trecord: RebaseRecord | null | undefined,\n\torigin: { originUrl?: string; originPushUrl?: string },\n): void {\n\tif (\n\t\t(record?.originUrl && origin.originUrl !== record.originUrl) ||\n\t\t(record?.originPushUrl && origin.originPushUrl !== record.originPushUrl)\n\t)\n\t\tthrow new Error(\"Rebase origin changed since preparation\");\n}\n\n/** A repair may operate only on the clean tracked checkout. @internal */\nexport function requireRebaseWorktree(\n\tworkBranch: string,\n\tobservation: { branch: string; dirty: boolean },\n): void {\n\tif (observation.branch !== workBranch) throw new Error(\"Expected tracked work branch for rebase\");\n\tif (observation.dirty)\n\t\tthrow new Error(\"Rebase requires a clean worktree with no unresolved conflicts\");\n}\n\n/** Both local and remote heads must still match the provider's evidence. @internal */\nexport function requireRebaseHead(expected: string, local: string, remote: string): void {\n\tif (remote !== expected || local !== expected)\n\t\tthrow new Error(\"Tracked branch changed before repair\");\n}\n\n/** Recognize a completed write without accepting somebody else's remote update. @internal */\nexport function rebasePublicationDecision(\n\toriginalHead: string,\n\theadSha: string,\n\tremoteHead: string,\n): \"already_published\" | \"push\" {\n\tif (remoteHead === headSha) return \"already_published\";\n\tif (remoteHead !== originalHead)\n\t\tthrow new Error(\"Concurrent remote change rejected by rebase lease\");\n\treturn \"push\";\n}\n","/** @internal */\nexport const rebasePrompt = `Repair only the recorded pull request merge conflict or behind-base condition. Deterministic preparation has fetched and verified the tracked head and current base, retained the original head and lease in .git/leitwerk-rebase.json, and started the rebase if the conflict or missing base commits are confirmed locally. Inspect that metadata and git status first. For behind-base evidence, incorporate the fetched base even when merging would be clean. A clean preparation result means no rewrite is needed. Resolve conflicts preserving the requested behavior, original authors, and existing Signed-off-by trailers. You may use git add and GIT_EDITOR=true git rebase --continue until finished. This explicitly overrides the prohibition on creating commits only for rebase continuation. Do not create unrelated commits, reset the branch, skip commits, abort the rebase, or push. Run focused repository checks after resolution. Delivery verifies the completed rebase and publishes with the recorded pre-repair lease. If blocked, retain the workspace and explain the failure for retry or abort. Record a concise repair result.`;\n","import type {\n\tdefineExternalActionSource,\n\tProcessWatcherDefinition,\n\tRepositoryFeedbackSourceConfig,\n\tRepositoryIssueCancelledSourceConfig,\n\tRepositoryPullRequestSourceConfig,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { GitIdentity } from \"./finalization-git.js\";\nimport type { RepositoryIssueOriginParams } from \"./repository-change-launch-internal.js\";\nimport {\n\tcreateRepositoryChangeProcess,\n\ttype RepositoryChangeProcessConfig,\n} from \"./repository-change-process.js\";\nimport type {\n\tPublicationContext,\n\tPublicationEvidence,\n\tPublicationParams,\n\tPublicationRequest,\n\tPublicationSource,\n\tPublicationState,\n\tPublicationReconciliationContext as RemoteContext,\n\tRepositoryChangePublicationAdapter,\n} from \"./repository-change-publication.js\";\nimport {\n\tcreateRepositoryChangePublication,\n\tpublicationObject as object,\n\treadPublicationState,\n} from \"./repository-change-publication.js\";\nimport type { RepositoryChangeState } from \"./repository-change-state.js\";\n\n/** Shared process defaults for SSH-backed pull-request publication. @internal */\nexport function createPullRequestChangeProcess<\n\tP extends PublicationParams & {\n\t\t/** @internal */\n\t\tsshCredentialRef: string;\n\t},\n\tE,\n\tC,\n>(\n\tprovider: string,\n\tlabel: string,\n\tdocker: boolean,\n\tconfig: Pick<RepositoryChangeProcessConfig<P>, \"paramsCodec\" | \"launcher\" | \"workflow\"> & {\n\t\t/** @internal */ publication: RepositoryChangePublicationAdapter<P>;\n\t\t/** @internal */ watcher: Omit<\n\t\t\tProcessWatcherDefinition<P, E, C>,\n\t\t\t\"id\" | \"label\" | \"description\"\n\t\t>;\n\t},\n) {\n\tconst { watcher, publication: adapter, ...definition } = config;\n\tconst publication = createRepositoryChangePublication(adapter);\n\tpublication.fragment.watcher({\n\t\t...watcher,\n\t\tid: \"use_leitwerk\",\n\t\tlabel: `${label} use-leitwerk issues`,\n\t\tdescription: `Launch a remote repository change for ${label} issues carrying the trigger label`,\n\t});\n\tconst { process } = createRepositoryChangeProcess({\n\t\t...definition,\n\t\tpublication,\n\t\tprocessId: `${provider}_repo_change_process`,\n\t\tdisplayName: `${label} Repo Change`,\n\t\trepositoryCredentials: ({ params }) => [\n\t\t\t{ projectKey: \"repo\", kind: \"git_ssh\", credentialRef: params.sshCredentialRef },\n\t\t],\n\t});\n\tprocess.runtime = { ...process.runtime, docker };\n\treturn process;\n}\n\n/** Tools implementing the shared pull-request publication protocol. @internal */\nfunction pullRequestDeliveryTools(provider: string): string[] {\n\treturn [\n\t\t\"get_pull_request\",\n\t\t\"add_pull_request_comment\",\n\t\t\"resolve_git_identity\",\n\t\t\"ensure_pull_request\",\n\t\t\"add_issue_comment\",\n\t\t\"add_pull_request_feedback_reaction\",\n\t\t\"reply_to_pull_request_feedback\",\n\t\t\"get_issue\",\n\t\t\"ensure_label\",\n\t\t\"update_issue\",\n\t].map((name) => `${provider}_${name}`);\n}\n\nconst callFor =\n\t(ctx: Pick<PublicationContext<unknown>, \"callIntegrationTool\">, provider: string) =>\n\t<T>(name: string, args: Record<string, unknown>) =>\n\t\tctx.callIntegrationTool(`${provider}_${name}`, { projectKey: \"repo\", ...args }) as Promise<T>;\n\n/** @internal */\nexport async function resolvePullRequestGitIdentity<P>(\n\tctx: PublicationContext<P>,\n\tprovider: string,\n\tprofile: string,\n\tallowLookup = true,\n): Promise<GitIdentity> {\n\tconst project = ctx.repo.get(\"repo\");\n\tconst metadata = ctx.projects.find((candidate) => candidate.key === project.key)?.metadata;\n\tconst identity = object(metadata?.[\"leitwerk.gitIdentity\"]);\n\tif (\n\t\tidentity.provider === provider &&\n\t\tidentity.profile === profile &&\n\t\t(!allowLookup || (typeof identity.login === \"string\" && identity.login.trim())) &&\n\t\t[identity.name, identity.email].every((value) => typeof value === \"string\" && value.trim())\n\t)\n\t\treturn identity as unknown as GitIdentity;\n\tif (!allowLookup) throw new Error(`Pinned ${provider} Git identity is unavailable`);\n\treturn callFor(ctx, provider)<GitIdentity>(\"resolve_git_identity\", {});\n}\n\n/** @internal */\nfunction readPullRequestFeedback(\n\tcurrent: PublicationState,\n\tevent: unknown,\n): Extract<PublicationEvidence, { kind: \"feedback\" }> {\n\tconst value = object(event);\n\tconst cursors = object(value.cursors);\n\treturn {\n\t\tkind: \"feedback\",\n\t\tconversationCursor: Number(cursors.conversationCursor ?? current.conversationCursor),\n\t\treviewCursor: Number(cursors.reviewCursor ?? current.reviewCursor),\n\t\tinlineCursor: Number(cursors.inlineCursor ?? current.inlineCursor),\n\t\tfeedbackIds: (value.feedbackIds ?? []) as PublicationState[\"feedbackIds\"],\n\t};\n}\n\n/** @internal */\ntype SourceFactory<C> = ReturnType<typeof defineExternalActionSource<C>>;\n\n/** Shared wiring for providers implementing the pull-request source protocol. @internal */\nexport function pullRequestPublicationDefaults<P extends PublicationParams>(\n\tprovider: string,\n\tlabel: string,\n\texternal: {\n\t\t/** @internal */\n\t\tpullRequestFeedback: SourceFactory<\n\t\t\tOmit<RepositoryFeedbackSourceConfig, \"disabled\" | \"terminalOutcome\">\n\t\t>;\n\t\t/** @internal */\n\t\tpullRequestTerminal: SourceFactory<Omit<RepositoryPullRequestSourceConfig, \"disabled\">>;\n\t\t/** @internal */\n\t\tissueCancelled: SourceFactory<RepositoryIssueCancelledSourceConfig>;\n\t},\n\tprofile: (params: P) => string,\n\tissueOrigin: (params: P) => RepositoryIssueOriginParams | undefined,\n\tlabelKey: \"id\" | \"name\",\n\tci: {\n\t\t/** @internal */ id: string;\n\t\t/** @internal */ label: string;\n\t\t/** @internal */ tools: readonly string[];\n\t\t/** @internal */ prompt(current: PublicationState): string;\n\t},\n) {\n\tconst remote = (state: RepositoryChangeState) =>\n\t\treadPublicationState(state, `${provider}RepoChange`);\n\t/** @internal */\n\tfunction requirePr(state: RepositoryChangeState) {\n\t\tconst value = remote(state);\n\t\tif (!value.headSha || !value.prNumber || !value.prUrl)\n\t\t\tthrow new Error(\"Pull request delivery state is incomplete\");\n\t\treturn {\n\t\t\t...value,\n\t\t\t/** @internal */ headSha: value.headSha,\n\t\t\t/** @internal */ prNumber: value.prNumber,\n\t\t\t/** @internal */ prUrl: value.prUrl,\n\t\t};\n\t}\n\tconst feedback: PublicationSource<P> = {\n\t\tid: `${provider}_feedback`,\n\t\tkind: \"feedback\",\n\t\tlabel: `${label} pull request feedback`,\n\t\tsource: external.pullRequestFeedback<P, RepositoryChangeState>(({ params, state }) => ({\n\t\t\tprofile: profile(params),\n\t\t\towner: params.owner,\n\t\t\trepo: params.repo,\n\t\t\tprNumber: requirePr(state).prNumber,\n\t\t\tconversationCursor: remote(state).conversationCursor,\n\t\t\treviewCursor: remote(state).reviewCursor,\n\t\t\tinlineCursor: remote(state).inlineCursor,\n\t\t\tquietPeriodMs: 120000,\n\t\t\tpollInterval: \"30s\",\n\t\t})),\n\t\tread: ({ state, event }) => readPullRequestFeedback(remote(state), event),\n\t};\n\tconst terminal: PublicationSource<P>[] = ([\"merged\", \"closed\"] as const).map(\n\t\t(terminalOutcome) => ({\n\t\t\tid: `${provider}_pr_${terminalOutcome}`,\n\t\t\tkind: \"terminal\",\n\t\t\tlabel: `${label} pull request ${terminalOutcome}`,\n\t\t\tsource: external.pullRequestTerminal<P, RepositoryChangeState>(({ params, state }) => ({\n\t\t\t\tprofile: profile(params),\n\t\t\t\towner: params.owner,\n\t\t\t\trepo: params.repo,\n\t\t\t\tprNumber: requirePr(state).prNumber,\n\t\t\t\tterminalOutcome,\n\t\t\t\tpollInterval: \"30s\",\n\t\t\t})),\n\t\t\tread: ({ event }) => ({\n\t\t\t\tkind: \"terminal\",\n\t\t\t\trequest: object(event).pullRequest as PublicationRequest,\n\t\t\t}),\n\t\t}),\n\t);\n\tconst cancelled: PublicationSource<P> = {\n\t\tid: \"source_cancelled\",\n\t\tkind: \"cancelled\",\n\t\tlabel: \"Source issue cancelled\",\n\t\tenabled: (params) => issueOrigin(params) !== undefined,\n\t\tsource: external.issueCancelled<P, RepositoryChangeState>(({ params }) => {\n\t\t\tconst issue = issueOrigin(params);\n\t\t\tif (!issue) throw new Error(`${label} source issue metadata is unavailable`);\n\t\t\treturn {\n\t\t\t\tprofile: profile(params),\n\t\t\t\towner: params.owner,\n\t\t\t\trepo: params.repo,\n\t\t\t\tissueNumber: issue.issueNumber,\n\t\t\t\ttriggerLabel: issue.triggerLabel,\n\t\t\t\tpollInterval: \"30s\",\n\t\t\t};\n\t\t}),\n\t\tread: () => ({ kind: \"cancelled\" }),\n\t};\n\tasync function finalizeIssue(ctx: RemoteContext<P>, pr: PublicationRequest | null) {\n\t\tconst params = issueOrigin(ctx.params);\n\t\tif (!params) return;\n\t\tconst call = callFor(ctx, provider);\n\t\tconst issue = await call<{ labels: Array<{ id: number; name: string }> }>(\"get_issue\", {\n\t\t\tissueNumber: params.issueNumber,\n\t\t});\n\t\tlet labels = issue.labels\n\t\t\t.filter((label) => label.name !== params.triggerLabel)\n\t\t\t.map((label) => label[labelKey]);\n\t\tif (pr?.merged) {\n\t\t\tconst done = await call<{ id: number; name: string }>(\"ensure_label\", {\n\t\t\t\tname: params.doneLabel,\n\t\t\t});\n\t\t\tlabels = [...new Set([...labels, done[labelKey]])];\n\t\t}\n\t\tawait call(\"update_issue\", {\n\t\t\tissueNumber: params.issueNumber,\n\t\t\tpatch: { labels, ...(pr?.merged ? { state: \"closed\" } : {}) },\n\t\t\twriteKey: `${provider}:${ctx.process.id}:${pr?.merged ? \"complete-source-issue\" : pr ? \"remove-source-trigger\" : \"no-changes-trigger\"}`,\n\t\t});\n\t\tawait call(\"add_issue_comment\", {\n\t\t\tissueNumber: params.issueNumber,\n\t\t\tbody: !pr\n\t\t\t\t? \"No repository changes were needed. No pull request was opened.\"\n\t\t\t\t: pr.merged\n\t\t\t\t\t? `Merged ${pr.html_url}${pr.merge_commit_sha ? ` at ${pr.merge_commit_sha}` : \"\"}.`\n\t\t\t\t\t: `Leitwerk stopped because ${pr.html_url} was closed without merge.`,\n\t\t\twriteKey: `${provider}:${ctx.process.id}:${pr ? `${pr.merged ? \"merged\" : \"closed\"}-pr-comment` : \"no-changes-comment\"}`,\n\t\t});\n\t}\n\tconst call = (ctx: PublicationContext<P>) => callFor(ctx, provider);\n\tconst adapter: Omit<RepositoryChangePublicationAdapter<P>, \"sources\"> = {\n\t\t/** @internal */ namespace: `${provider}RepoChange`,\n\t\t/** @internal */ label: `${label} PR`,\n\t\t/** @internal */ ids: {\n\t\t\t/** @internal */ deliver: \"deliver_change\",\n\t\t\t/** @internal */ feedback: \"revise_from_pull_request_feedback\",\n\t\t\t/** @internal */ ciRepair: ci.id,\n\t\t\t/** @internal */ operator: \"ci_operator_action\",\n\t\t},\n\t\t/** @internal */ tools: {\n\t\t\t/** @internal */ delivery: pullRequestDeliveryTools(provider),\n\t\t\t/** @internal */ feedback: [\n\t\t\t\t`${provider}_get_pull_request`,\n\t\t\t\t`${provider}_list_pull_request_feedback`,\n\t\t\t],\n\t\t\t/** @internal */ ci: ci.tools,\n\t\t},\n\t\t/** @internal */ commitMessage: (kind: \"feedback\" | \"ci\") =>\n\t\t\tkind === \"feedback\" ? `fix: address ${label} review feedback` : `fix: repair ${ci.label}`,\n\t\t/** @internal */ prompt: (kind: \"feedback\" | \"ci\", current: PublicationState) =>\n\t\t\tkind === \"feedback\"\n\t\t\t\t? `Address the unseen ${label} pull-request feedback batch for PR #${current.prNumber}. Feedback identifiers: ${JSON.stringify(current.feedbackIds)}. Inspect the current checkout and use ${label} tools to read the full feedback. Do not rely on an earlier plan or conversation. Make only justified repository changes. Call changes_ready if files need publishing, no_changes after an explicit diagnosis that no repository change is needed, or cannot_repair when operator action is required.`\n\t\t\t\t: ci.prompt(current),\n\t\t/** @internal */ identity: (ctx: PublicationContext<P>) =>\n\t\t\tresolvePullRequestGitIdentity(ctx, provider, profile(ctx.params)),\n\t\t/** @internal */ reconcileTerminal: (ctx, _current, pr) => finalizeIssue(ctx, pr),\n\t\t/** @internal */ unchanged: (ctx) => finalizeIssue(ctx, null),\n\t\tasync ensureRequest(ctx) {\n\t\t\tconst project = ctx.repo.get(\"repo\");\n\t\t\tconst issue = issueOrigin(ctx.params);\n\t\t\tconst pr = await call(ctx)<PublicationRequest>(\"ensure_pull_request\", {\n\t\t\t\ttitle: ctx.process.title ?? (issue ? `Issue #${issue.issueNumber}` : \"Leitwerk change\"),\n\t\t\t\tbody: issue\n\t\t\t\t\t? `Implements ${issue.issueUrl}\\n\\nLeitwerk process: ${ctx.process.id}`\n\t\t\t\t\t: `Leitwerk process: ${ctx.process.id}`,\n\t\t\t\thead: project.workBranch,\n\t\t\t\tbase: project.baseBranch,\n\t\t\t});\n\t\t\tif (!pr) throw new Error(`${label} pull request could not be created or found`);\n\t\t\treturn pr;\n\t\t},\n\t\tasync linkIssue(ctx, current) {\n\t\t\tconst issue = issueOrigin(ctx.params);\n\t\t\tif (issue)\n\t\t\t\tawait call(ctx)(\"add_issue_comment\", {\n\t\t\t\t\tissueNumber: issue.issueNumber,\n\t\t\t\t\tbody: `Leitwerk opened pull request ${current.prUrl}.`,\n\t\t\t\t\twriteKey: `${provider}:${ctx.process.id}:source-pr-link:${current.prNumber}`,\n\t\t\t\t});\n\t\t},\n\t\tasync reply(ctx, current) {\n\t\t\tconst invoke = call(ctx);\n\t\t\tfor (const feedback of current.feedbackIds)\n\t\t\t\tawait invoke(\"reply_to_pull_request_feedback\", {\n\t\t\t\t\tpullRequestNumber: current.prNumber,\n\t\t\t\t\tfeedbackKind: feedback.kind,\n\t\t\t\t\tfeedbackId: feedback.id,\n\t\t\t\t\tbody: `Addressed in ${current.headSha?.slice(0, 8) ?? \"the current revision\"}.`,\n\t\t\t\t\twriteKey: `${provider}:${ctx.process.id}:feedback-reply:${feedback.kind}:${feedback.id}:${current.headSha}`,\n\t\t\t\t});\n\t\t},\n\t\tasync acknowledge(ctx, current) {\n\t\t\tconst invoke = call(ctx);\n\t\t\tfor (const feedback of current.feedbackIds) {\n\t\t\t\tif (feedback.kind === \"review\") continue;\n\t\t\t\tawait invoke(\"add_pull_request_feedback_reaction\", {\n\t\t\t\t\tpullRequestNumber: current.prNumber,\n\t\t\t\t\tfeedbackKind: feedback.kind,\n\t\t\t\t\tfeedbackId: feedback.id,\n\t\t\t\t\twriteKey: `${provider}:${ctx.process.id}:feedback-eyes:${feedback.kind}:${feedback.id}`,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tasync head(ctx, current) {\n\t\t\treturn (\n\t\t\t\tawait call(ctx)<{ head: { sha: string } }>(\"get_pull_request\", {\n\t\t\t\t\tpullRequestNumber: current.prNumber,\n\t\t\t\t})\n\t\t\t).head.sha;\n\t\t},\n\t\tasync afterRebase(ctx, current) {\n\t\t\tawait call(ctx)(\"add_pull_request_comment\", {\n\t\t\t\tpullRequestNumber: current.prNumber,\n\t\t\t\tbody: `Merge conflict repair completed at ${current.headSha}; base ${current.conflict?.baseSha}.`,\n\t\t\t\twriteKey: `rebase:${ctx.process.id}:${current.lastConflictKey}:${current.headSha}`,\n\t\t\t});\n\t\t},\n\t};\n\treturn {\n\t\t/** @internal */ adapter,\n\t\t/** @internal */ conflict(source: PublicationSource<P>[\"source\"]): PublicationSource<P> {\n\t\t\treturn {\n\t\t\t\tid: `${provider}_merge_conflict`,\n\t\t\t\tkind: \"conflict\",\n\t\t\t\tlabel: \"Rebase conflicting pull request\",\n\t\t\t\tsource,\n\t\t\t\tread: ({ event }) => ({\n\t\t\t\t\tkind: \"conflict\",\n\t\t\t\t\tconflict: object(event).conflict as NonNullable<PublicationState[\"conflict\"]>,\n\t\t\t\t}),\n\t\t\t};\n\t\t},\n\t\t/** @internal */ requirePr,\n\t\t/** @internal */ feedback,\n\t\t/** @internal */ terminal,\n\t\t/** @internal */ cancelled,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,uBAAuB;AAChC;AAAA,EAKC;AAAA,OAEM;;;ACRP,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,mBAAmB,kCAAkC;AAC9D,SAAS,wBAAwB;;;ACmB1B,SAAS,oBACf,YACA,UACA,QACO;AACP,MAAI,eAAe,SAAS,cAAc,eAAe,SAAS;AACjE,UAAM,IAAI,MAAM,mEAAmE;AACpF,MAAI,WAAW,OAAO,WAAW,cAAc,OAAO,iBAAiB,SAAS;AAC/E,UAAM,IAAI,MAAM,kCAAkC;AACnD,MAAI,QAAQ,cAAc,OAAO,eAAe,SAAS;AACxD,UAAM,IAAI,MAAM,8CAA8C;AAChE;AAGO,SAAS,oBACf,QACA,QACO;AACP,MACE,QAAQ,aAAa,OAAO,cAAc,OAAO,aACjD,QAAQ,iBAAiB,OAAO,kBAAkB,OAAO;AAE1D,UAAM,IAAI,MAAM,yCAAyC;AAC3D;AAGO,SAAS,sBACf,YACA,aACO;AACP,MAAI,YAAY,WAAW,WAAY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K,EAAE,iBAAiB,YACnC,OAAO,IAAI,KAAK,EAAE,iBAAiB,cACnC,OAAO,IAAI,KAAK,EAAE,yBACf,aACA;AAAA,QACL;AAAA,QACA,gBAAgB;AAAA,UACf,OAAO;AAAA,UACP,iBAAiB;AAAA,UACjB,IAAI,IAAI;AAAA,UACR,QAAQ,CAAC,EAAE,IAAI,OAAO;AAAA,YACrB,OAAO,YAAY,IAAI,OAAO;AAAA,cAC7B,eAAe;AAAA,cACf,aAAa,CAAC;AAAA,cACd,UAAU,EAAE,YAAY,KAAK;AAAA,YAC9B,CAAC;AAAA,UACF;AAAA,QACD;AAAA,QACA,OAAO,EAAE,OAAO,iBAAiB,iBAAiB,WAAW,iBAAiB,UAAU;AAAA,MACzF;AAAA,IACD;AAAA,EACD,CAAC;AAED,SAAO;AAAA;AAAA,IAEN,aAAa,IAAI;AAAA;AAAA,IAGjB,UAAU;AAAA;AAAA,IAGV,WAAW,CAAC,IAAI,OAAO;AAAA;AAAA,IAEvB,mBAAmB,QAAQ;AAAA,EAC5B;AACD;","names":["call","label","feedback","label","outcome","state","prepareRebase"]}
@@ -1,17 +1,18 @@
1
1
  import type { GitIdentity } from "./finalization-git.js";
2
- /** @internal */
3
- export interface ReconciliationInput {
2
+ type RepositoryLocation = {
4
3
  projectKey: string;
5
4
  repoPath: string;
5
+ };
6
+ type WorkBranch = RepositoryLocation & {
6
7
  workBranch: string;
8
+ };
9
+ type ReconciliationInput = WorkBranch & {
7
10
  /** Last remote baseline, not the latest observation. */
8
- baselineSha: string;
9
- /** Trusted project identity for replaying unpublished commits. */
10
- gitIdentity?: GitIdentity;
11
- }
12
- type WorkBranchInput = Omit<ReconciliationInput, "baselineSha"> & {
13
11
  baselineSha?: string;
14
12
  baseBranch?: string;
13
+ protectSubmodules?: boolean;
14
+ /** Trusted project identity for replaying unpublished commits. */
15
+ gitIdentity?: GitIdentity;
15
16
  };
16
17
  /** @internal */
17
18
  export interface ReconciliationResult {
@@ -20,21 +21,22 @@ export interface ReconciliationResult {
20
21
  headSha: string;
21
22
  }
22
23
  /** Reject ignored-file collisions before a target checkout/rebase can overwrite them. @internal */
23
- export declare function assertReconciliationTargetSafe(input: Pick<ReconciliationInput, "repoPath" | "projectKey">, targetSha: string): void;
24
+ export declare function assertReconciliationTargetSafe(input: RepositoryLocation, targetSha: string): void;
24
25
  /** Preserve a target rebase as a net local delta when its source lease changes. @internal */
25
- export declare function retainConcurrentRebase(input: ReconciliationInput & {
26
+ export declare function retainConcurrentRebase(input: WorkBranch & {
27
+ baselineSha: string;
26
28
  rebasedHead: string;
27
29
  targetBase: string;
28
30
  gitIdentity: GitIdentity;
29
31
  }): void;
30
32
  /** @internal */
31
- export declare function repositoryWorktreeIsDirty(input: Pick<ReconciliationInput, "repoPath" | "projectKey">): boolean;
33
+ export declare function repositoryWorktreeIsDirty(input: RepositoryLocation): boolean;
32
34
  /** Capture the baseline before the first implementation, including an unpublished branch. @internal */
33
- export declare function prepareInitialRepository(input: Omit<WorkBranchInput, "baselineSha">): ReconciliationResult;
35
+ export declare function prepareInitialRepository(input: Omit<ReconciliationInput, "baselineSha">): ReconciliationResult;
34
36
  /** Missing branches are allowed only before first publication. @internal */
35
- export declare function reconcilePublicationRepository(input: WorkBranchInput): ReconciliationResult;
37
+ export declare function reconcilePublicationRepository(input: ReconciliationInput): ReconciliationResult;
36
38
  /** Record only a remotely verified publication, including recovery after a lost reply. @internal */
37
- export declare function recordRepositoryPublication(input: Omit<ReconciliationInput, "baselineSha" | "gitIdentity">, headSha: string): void;
39
+ export declare function recordRepositoryPublication(input: WorkBranch, headSha: string): void;
38
40
  /** @internal */
39
41
  export declare 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.";
40
42
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"repository-reconciliation.d.ts","sourceRoot":"","sources":["../src/repository-reconciliation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAUzD,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,WAAW,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED,KAAK,eAAe,GAAG,IAAI,CAAC,mBAAmB,EAAE,aAAa,CAAC,GAAG;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACpC,MAAM,EAAE,WAAW,GAAG,YAAY,GAAG,WAAW,CAAC;IACjD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CAChB;AAmdD,mGAAmG;AACnG,wBAAgB,8BAA8B,CAC7C,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,GAAG,YAAY,CAAC,EAC3D,SAAS,EAAE,MAAM,GACf,IAAI,CAKN;AAED,6FAA6F;AAC7F,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,mBAAmB,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;CACzB,GACC,I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