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

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