@leitwerk-dev/jira-gitlab-change 0.0.0-stage → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,233 @@
1
- # Temporary Holding Version
1
+ # Jira GitLab change
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@leitwerk-dev/jira-gitlab-change` launches one process for a Jira issue across its
4
+ component-mapped GitLab repositories. Load `jira`, `gitlab`, `coding`, and this
5
+ extension. Load `git-ssh` only when using SSH mappings. It is opt-in; no deployment
6
+ or automatic merge is implied.
7
+
8
+ ```yaml
9
+ process_configs:
10
+ jira_gitlab_change_process:
11
+ watchers:
12
+ use_leitwerk:
13
+ enabled: true
14
+ profile: team
15
+ projects: ['10000', '10001']
16
+ poll_interval: 30s
17
+ label: use-leitwerk # use-leitwerk-beta for a separate beta trigger
18
+ ```
19
+
20
+ The watcher label defaults to `use-leitwerk`. Admission retains the selected trigger
21
+ for eligibility, cancellation, approval bypass and final label removal. Changing the
22
+ watcher configuration does not retarget existing runs. The immutable issue identity
23
+ still deduplicates launches across labels and restarts.
24
+
25
+ Optional model labels select an instance default at admission:
26
+
27
+ ```yaml
28
+ extensions:
29
+ jira-gitlab-change:
30
+ verification_on_merge: false # opt in to the completion transition
31
+ verification_status: In Verification # or Ready for Verification
32
+ model_labels:
33
+ leitwerk-model-astra: astra-high
34
+ leitwerk-model-sol: sol-medium
35
+ leitwerk-model-luna: luna-medium
36
+ ```
37
+
38
+ Values refer to registered, process-allowed model profile IDs. Without a model label,
39
+ normal watcher/process defaults apply. One label overrides the watcher default;
40
+ explicit per-turn overrides retain precedence. Unknown or multiple `leitwerk-model-*`
41
+ labels and unavailable profiles reject admission and remain retryable. The captured
42
+ label/profile selection survives restarts and label reapplication. Later Jira edits
43
+ do not switch the model of an existing run; use its Leitwerk model settings. Model
44
+ labels alone do not trigger a change.
45
+
46
+ In Settings, refresh sources, select a Jira component, and override **GitLab
47
+ repositories**. Values load immediately; repository options load in the editor.
48
+ Opening the editor shows saved selections and a search field without loading
49
+ options. Enter at least two characters to search GitLab; each query returns up to
50
+ 100 matches per profile and repeated queries reuse cached results. Saved selections
51
+ stay visible while searching. **Refresh sources** explicitly rescans GitLab and
52
+ subsequent searches reuse that catalog.
53
+ Repository names from discovery and searches are retained by GitLab origin and
54
+ project ID. Saved selections show the full repository path after a restart, even
55
+ when GitLab is unavailable; only repositories without a known name use their ID.
56
+ Refreshing sources updates names without rewriting component mappings.
57
+ Select repositories with their GitLab profile and **HTTPS** to use
58
+ the profile's access token for clone and push. No SSH key or known-host configuration
59
+ is needed. The token needs API access and repository write permission (`api` and
60
+ `write_repository` scopes). If `git-ssh` is loaded, mappings may instead select an SSH
61
+ profile with pinned host keys. Repository identity uses the GitLab installation and
62
+ stable project ID. Every Jira component must map to at least one repository; the
63
+ component union removes duplicate repositories. Missing mappings create a process
64
+ in **Waiting** at Plan, with the component names and instructions to configure
65
+ **Settings → Jira components → GitLab repositories**. Issues without components
66
+ also wait, with instructions to assign one. No worker, turn attempt, Jira status
67
+ transition or publication occurs while startup is blocked.
68
+
69
+ Startup rechecks every 30 seconds and resumes the same process automatically when
70
+ all components are mapped. It rereads issue content and mappings while waiting,
71
+ retains the original trigger, watcher project scope and model selection, and
72
+ survives server restarts. Stop or source cancellation prevents automatic startup.
73
+ Transient provider failures back off; other invalid repository/profile selections
74
+ require correction and the standard Retry action after process creation. Fully
75
+ mapped launches retain their admission checks. Every repository must pass read and
76
+ dry-run write preflight through its selected transport. Jira credentials remain on
77
+ the server. GitLab HTTPS tokens or SSH credentials reach the selected worker through
78
+ authenticated credential delivery, never through snapshots or repository URLs.
79
+
80
+ Admission rechecks the issue and mappings, then retains issue content, mapping
81
+ revisions, repository identities, profile references, and branches. Subsequent
82
+ mapping edits affect later launches once the binding is resolved. Pending startup
83
+ captures and binds the complete repository set atomically before worker preparation.
84
+ Workers prepare declared repository tools before readiness and turn acceptance.
85
+ The work branch is `leitwerk/jira-<installation-hash>-<issue-id>`.
86
+ The recheck compares the issue revision and launch-relevant fields; changing
87
+ plugin display data or viewing metadata alone does not reject an unchanged issue.
88
+ Source descriptions are converted from Jira wiki markup to Markdown for launch
89
+ prompts and future LLM turns. Conversion uses captured issue evidence; historical
90
+ prompts and raw snapshots remain intact.
91
+ Each repository has its own checkout, commit message, MR, head, feedback cursor,
92
+ conflict evidence, and CI repair count. Models use installation defaults until a
93
+ primary repository is bound in process settings.
94
+
95
+ Tickets generated by the issue splitter use their retained exact repository binding,
96
+ not the whole component union. Mapping/profile or source issue membership drift blocks
97
+ admission rather than silently retargeting the ticket. Newly launched changes for
98
+ any issue with an Epic Link join that epic's [solution wiki](../../docs/topic-wiki.md),
99
+ including manual tickets. Subtasks instead join their direct parent's wiki, including
100
+ when that parent belongs to an epic. Generated tickets verify their retained Epic Link
101
+ or subtask parent before admission. Existing running processes keep their captured membership.
102
+
103
+ Contribute only newly learned solutions useful to another process in that topic.
104
+ The solution must add knowledge absent from both the current ticket description
105
+ and the shared parent or epic requirement; repeating either does not qualify.
106
+ See the [wiki interface](../../packages/wiki/README.md) for evidence and revision rules.
107
+
108
+ Older split publication receipts may omit checkout credentials and clone URL.
109
+ Admission resolves them from the exact component mapping and current GitLab project,
110
+ then pins their references in the change snapshot. Mappings without an SSH profile
111
+ use HTTPS; existing SSH mappings and running snapshots retain SSH. Retained SSH
112
+ selections and clone URLs cannot silently switch transport. Repository paths, profile
113
+ selections, and base branches must still match. Receipt and wiki history are preserved. A retained wiki
114
+ topic may use a publisher-specific namespace; its installation URL and immutable
115
+ source issue ID must match before it can be reused.
116
+
117
+ ## Workflow
118
+
119
+ [Generated process graph](process.mmd). Dashed edges are external triggers; terminal
120
+ outcomes are separate from the ten registered turns.
121
+
122
+ | Turn | Kind | Route |
123
+ | --- | --- | --- |
124
+ | `generate_plan` | LLM | Plan decision, or implementation after bypass |
125
+ | `plan_decision` | Human | Approve → implement; comments → regenerate plan |
126
+ | `implement` | LLM | Simplification, or commit messages when skipped |
127
+ | `simplify_implementation` | LLM, read-only | Persist findings → apply simplification |
128
+ | `apply_simplification` | LLM | Apply findings and validate → commit messages |
129
+ | `generate_commit_message` | LLM | Persist messages by repository → deliver |
130
+ | `deliver_change` | Automatic | Publish initial work or a changed adjustment |
131
+ | `revise_from_merge_request_feedback` | LLM | Address feedback/conflicts → deliver |
132
+ | `repair_gitlab_pipeline` | LLM | Repair CI → deliver |
133
+ | `ci_operator_action` | Human | Retry repair, resume waiting, or abort |
134
+
135
+ Plan approval starts implementation and publication automatically. Plan revisions
136
+ accept human comments. `leitwerk-skip-plan-decision` bypasses approval when the plan
137
+ finishes or when the label is added while approval waits. A system approval records
138
+ the current plan revision and reason. Removing the label does not rewind work;
139
+ unavailable source reads never bypass approval.
140
+
141
+ The same label disables `ask_questions` during planning. Preparation reads the
142
+ current Jira labels and saves the question policy in its checkpoint. The planner
143
+ decides from the requirement and evidence and records minimal assumptions within
144
+ the requested scope. Continue and replacement workers reuse that policy; Retry
145
+ reads current labels again. An unavailable label read keeps questions enabled.
146
+
147
+ When planning begins, the process adds its public Leitwerk URL through Jira's native
148
+ link feature and transitions the ticket to **In Progress**. Delivery adds a native
149
+ Jira link for each MR. MR descriptions link directly to both the Jira ticket and the
150
+ Leitwerk process. The ticket enters **In Review** only after every changed repository
151
+ has a linked MR; repositories confirmed unchanged do not delay review. No-change
152
+ runs, cancellation and aborted outcomes do not enter review. The workflow posts no
153
+ automatic Jira comments, including completion summaries.
154
+
155
+ Simplification runs once before first publication. Immediately after implementation,
156
+ the latest Jira labels decide whether `leitwerk-skip-simplification` skips both
157
+ simplification turns. A failed lookup requires generic retry. The durable decision
158
+ survives recovery; label changes after the pair starts do not interrupt it.
159
+
160
+ Analysis uses this instruction for each checkout, labelling findings by repository:
161
+
162
+ > Review all uncommitted changes in this repo: staged, unstaged, and untracked files. Analyze what could be simplified to reduce the number of lines.
163
+ > Also look a bit around the current changes to identify points to save lines.
164
+
165
+ Application consumes the durable findings and accepted plan, applies justified
166
+ changes, preserves behavior, and reruns checks. Empty findings proceed normally.
167
+ Changes stay uncommitted until delivery. Later feedback, conflict, and CI repairs
168
+ return to delivery. No-change outcomes also pass through Deliver to recheck the
169
+ remote source branch and retained unpublished work before acknowledging feedback.
170
+ Developer pushes and rebases are reconciled without discarding local changes; the
171
+ combined result is validated before publication. See the
172
+ [shared reconciliation contract](../coding/README.md#source-branch-reconciliation).
173
+
174
+ ## Delivery and recovery
175
+
176
+ Only changed repositories publish MRs. Interrupted publication reconciles committed
177
+ branches, pinned MR identities, and durable external writes. MR observations correlate
178
+ repository, MR, and source revision. Human feedback settles for two minutes. Each
179
+ repository receives up to three automatic CI repairs before operator action.
180
+ Conflicts reuse the shared rebase and original-head push-lease implementation.
181
+ [Shared GitLab MR maintenance](../gitlab/README.md#shared-mr-maintenance) supplies
182
+ feedback/CI routing, ownership labels, fencing, and restart recovery without adding
183
+ business turns. Removing `leitwerk-active` stops only that MR and leaves it open;
184
+ other MRs continue. The outcome table below defines coordinated completion and
185
+ Jira label policy.
186
+
187
+ | External evidence | Route / outcome |
188
+ | --- | --- |
189
+ | Settled human MR feedback | Feedback revision, then delivery |
190
+ | Confirmed merge conflict | Feedback revision with rebase evidence |
191
+ | Current-head CI failure | CI repair, or operator action after three repairs |
192
+ | All created MRs merged | Complete; remove trigger, add `leitwerk-done` |
193
+ | Mixed merge and unmerged closure | Continue open MRs, then complete with a partial result; no Jira done label |
194
+ | Every MR closes unmerged | Abort with the recorded result; remove trigger |
195
+ | Some MRs stopped | Continue others; record stopped MRs in the partial result; no Jira done label |
196
+ | All changed MRs stopped unmerged | Abort; leave MRs open; no done label |
197
+ | Any linked MR deleted, with project access confirmed | Abort the whole process and cancel running work; no writes to the deleted MR |
198
+ | No repository changes | Complete without MRs; remove trigger; no done label |
199
+ | Source cancellation | Reconcile terminal MRs, stop further delivery, leave open MRs untouched |
200
+
201
+ Jira links, transitions and label mutations are durable external writes. Retries do
202
+ not create duplicate processes, MRs or links. Transitions are discovered by destination
203
+ status name; missing or ambiguous transitions and permission failures pause the owning
204
+ turn for generic retry. Planning retries do not move In Review back to In Progress or
205
+ reopen Done tickets. No automatic final-status transition is performed. Generic retry
206
+ handles failed lookups and interrupted turns. Operator abort and process history remain
207
+ available. GitLab profile `ignored_comment_users` excludes configured feedback authors
208
+ before settling; for example, `[sonarqube]` ignores that account's MR comments.
209
+
210
+ Before deploying the changed GitLab workflow, finish or abort active instances that
211
+ use removed review or approval turns. Retain their history. Deployment, automatic
212
+ merging, and Jira-comment-driven plan revisions are outside
213
+ this extension.
214
+
215
+ Set `extensions.jira-gitlab-change.verification_on_merge: true` to transition the
216
+ source issue to **In Verification** after all changed MRs merge. Set
217
+ `verification_status: Ready for Verification` to use that destination instead. This is disabled
218
+ by default. The Jira workflow must expose exactly one matching transition;
219
+ failed reconciliation retries safely and does not rewind later human status edits.
220
+
221
+ ## Repository mapping interface
222
+
223
+ Other extensions can resolve `jiraGitLabRepositories` through
224
+ `scopedSettingsCapability` and decode retained values with
225
+ `decodeJiraGitLabRepositoryMapping`. This extension owns the single registered
226
+ `jira-gitlab-change.repositories` field; consumers must not copy its storage format
227
+ or register a second mapping field. Preview choices contain retained selections;
228
+ use the choices endpoint to discover candidates and server validation for writes.
229
+
230
+ A component publication may retain `componentId` in its binding. Admission verifies
231
+ that identity against the ticket and resolves all repositories mapped to the
232
+ component. Legacy repository publications retain their original single-repository
233
+ binding and reconciliation rules.
package/dist/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2026 Leitwerk contributors.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,53 @@
1
+ import type { RepositoryChangeState } from "@leitwerk-dev/coding/repository-change-state";
2
+ import { type JiraIssue } from "@leitwerk-dev/jira";
3
+ import { type LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
4
+ import { type JiraGitLabParams } from "./launch.js";
5
+ export * from "./launch.js";
6
+ /** @public */
7
+ export declare function createJiraGitLabChange(options: {
8
+ /** @internal */
9
+ docker: boolean;
10
+ /** Opt into the supported Jira verification transition after all changed MRs merge. @internal */
11
+ verificationOnMerge?: boolean;
12
+ /** Destination for enabled completion transitions. @internal */
13
+ verificationStatus?: "In Verification" | "Ready for Verification";
14
+ }): {
15
+ /** @internal */
16
+ extension: LeitwerkExtensionModule;
17
+ /** @internal */
18
+ process: import("@leitwerk-dev/process-sdk").ExtensionProcessDefinition<JiraGitLabParams, RepositoryChangeState>;
19
+ /** @internal */
20
+ launcher: {
21
+ /** @internal */
22
+ ready: (context: Pick<import("@leitwerk-dev/process-sdk").TurnWaitContext<JiraGitLabParams>, "params" | "signal" | "waiting" | "abort" | "bindInitialProjects">) => Promise<true | import("@leitwerk-dev/process-sdk").TurnWaitDecision<JiraGitLabParams>>;
23
+ /** @internal */
24
+ mapping: import("@leitwerk-dev/process-sdk").SettingDefinition<string[]>;
25
+ /** @internal */
26
+ resolve: (event: import("@leitwerk-dev/jira").JiraWatcherEvent, ctx?: import("@leitwerk-dev/process-sdk").LauncherContext, retained?: JiraGitLabParams, signal?: AbortSignal) => Promise<import("@leitwerk-dev/process-sdk").ProcessLaunchConfig<JiraGitLabParams>>;
27
+ /** @internal */
28
+ checks: (event: import("@leitwerk-dev/jira").JiraWatcherEvent, launch: import("@leitwerk-dev/process-sdk").ProcessLaunchConfig<JiraGitLabParams>, retained?: JiraGitLabParams) => readonly import("@leitwerk-dev/process-sdk").LaunchPreparationCheck<JiraGitLabParams>[];
29
+ /** @internal */
30
+ configure(value: {
31
+ /** @internal */
32
+ jira: import("@leitwerk-dev/jira").JiraIntegration;
33
+ /** @internal */
34
+ gitlab: import("@leitwerk-dev/gitlab").GitLabIntegration;
35
+ /** @internal */
36
+ ssh?: import("@leitwerk-dev/git-ssh").GitSshIntegration;
37
+ /** @internal */
38
+ settings: import("@leitwerk-dev/process-sdk").ScopedSettingsResolver;
39
+ /** @internal */
40
+ wiki?: import("@leitwerk-dev/wiki").TopicWikiStore;
41
+ /** @internal */
42
+ publications?: import("@leitwerk-dev/external-writes").PublicationStore;
43
+ /** @internal */
44
+ modelLabels?: Readonly<Record<string, string>>;
45
+ } | null): void;
46
+ /** @internal */
47
+ readIssue(params: JiraGitLabParams): Promise<JiraIssue>;
48
+ };
49
+ };
50
+ /** @public */
51
+ export declare const defaultExtension: LeitwerkExtensionModule, jiraGitLabChangeProcess: import("@leitwerk-dev/process-sdk").ExtensionProcessDefinition<JiraGitLabParams, RepositoryChangeState>;
52
+ export default defaultExtension;
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAU1F,OAAO,EACN,KAAK,SAAS,EAMd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEN,KAAK,uBAAuB,EAE5B,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAEN,KAAK,gBAAgB,EAGrB,MAAM,aAAa,CAAC;AAGrB,cAAc,aAAa,CAAC;AAM5B,cAAc;AACd,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC/C,gBAAgB;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,iGAAiG;IACjG,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gEAAgE;IAChE,kBAAkB,CAAC,EAAE,iBAAiB,GAAG,wBAAwB,CAAC;CAClE;IAyOC,gBAAgB;;IAEhB,gBAAgB;;IAEhB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGjB;AAED,cAAc;AACd,eAAO,MAAmB,gBAAgB,2BAAW,uBAAuB,yGACnC,CAAC;AAC1C,eAAe,gBAAgB,CAAC"}