Extensible reference filters
<!-- The first four sections: "Problem to solve", "Intended users", "User experience goal", and "Proposal", are strongly recommended, while the rest of the sections can be filled out during the problem validation or breakdown phase. However, keep in mind that providing complete and relevant information early helps our product team validate the problem and start working on a solution. -->
### Problem to solve
> [!note]
> Note that we will no longer allow the addition of markdown character references. Only references in the form of `[refernce_name:identifier]` should be added.
We are running out of ASCII characters to use as prefixes in reference filter
short-codes. We already use `~!@#$%&` and are thinking of assigning `^` to
designs.
Short codes are great, and some (such as `#` and `@`) are almost ubiquitous in
usage across platforms. They make for an excellent autocomplete experience.
However, there are lots of different kinds of objects in GitLab, and it is not
unreasonable to want to reference them too, but when we run out of the top row
ASCII characters, that is going to hurt.
Current character assignments (See [GitLab Markdown docs](https://docs.gitlab.com/ee/user/markdown.html#special-gitlab-references) ):
- `~` Label
- `!` Merge Requests
- `@` User
- `#` Issue
- `$` Snippet
- `%` Milestone
- `&` Epic
### Intended users
This benefits all users, since all users are expected to read and write text on
the platform.
### User experience goal
We can freely add new reference filters without having to approach APL level
text-salad, and while remaining clear what each reference does.
### Proposal
We introduce a text-based syntax, with an easily parsed prefix, capable of
extension
<details>
<summary>Other options we explored:</summary>
#### 1. Handlebars
Use `{{$name:$args}}`:
```markdown
Can we move {{issue:123}} to {{milestone:1.1}}? I know it is part of {{epic:2}}
but it seems separate? I don't think it is {{label:workflow::in dev}} though!
Also, what about {{issue:some-group/proj-a/123}} and {{issue:some-group/proj-b/123}}? Should
we add them as well?
```
This would allow us to detect prefixes such as `{{user:` and dispatch to a
`user` autocomplete.
#### 2. Single character prefix
Use `^<filter-name>#<reference-content>`, since this has already been implemented for some of our reference types.
```markdown
Can we move ^issue#123 to ^milestone#1.1? I know it is part of ^epic#2
but it seems separate? I don't think it is ^label#"workflow::in dev" though!
Also, what about ^issue#some-group/proj-a/123 and ^issue#some-group/proj-b/123? Should
we add them as well?
And should we split ^vulnerability#929 into its own issue? I see ^vuln#some-group/proj-c/323
is the same, so maybe do them at the same time.
```
#### 3. Use MDX
This embeds XML-elements with custom semantics:
```markdown
Can we move <Issue iid="123"> to <Milestone title="1.1">? I know it is part of <Epic iid="2">
but it seems separate? I don't think it is <Label title="workflow::in dev"> though!
Also, what about <Issue path="some-group/proj-a" iid="123"/> and <Issue path="some-group/proj-b" iid="123"/> Should
we add them as well?
```
This has the benefit of being an existing standard with known escaping rules.
</details>
#### Use markdown references
Markdown already has built-in references, using the syntax `[issue:45119]`. So it's a familiar syntax and visually looks like other links. [Discussion thread](https://gitlab.com/gitlab-org/gitlab/-/issues/217614#note_432056373)
```markdown
Can we move [issue:123] to [milestone:1.1]? I know it is part of [epic:2]
but it seems separate? I don't think it is [label:workflow::in dev] though!
Also, what about [issue:some-group/proj-a/123] and [issue:some-group/proj-b/123]? Should
we add them as well?
And should we split [vulnerability:929] into its own issue? I see [vuln:some-group/proj-c/323]
is the same, so maybe do them at the same time.
```
This is similar to Trac syntax
---
#### Proposed reference table (using markdown reference link style)
| references | input | cross-project reference | shortcut within same namespace |
|------------------------------------------------------|-------------------------------------------------------------|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| specific user | `@user_name`<br>`[user:username]` | | |
| specific group | `@group_name`<br>`[user:group_name]` | | |
| entire team | `@all`<br>`[user:all]` | | |
| project | `namespace/project>`<br>`[project:namespace/project]` | | |
| issue | ``#123``<br>`[issue:123]` | `namespace/project#123`<br>`[issue:namespace/project/123]` | `project#123`<br>`[issue:project/123]` |
| merge request | `!123`<br>`[mr:123]` | `namespace/project!123`<br>`[mr:namespace/project/123]` | `project!123`<br>`[mr:project/123]` |
| snippet | `$123`<br>`[snippet:123]` | `namespace/project$123`<br>`[snippet:namespace/project/123]` | `project$123`<br>`[snippet:project/123]` |
| epic **(ULTIMATE)** | `&123`<br>`[epic:123]` | `group1/subgroup&123`<br>`[epic:group1/subgroup/123]` | |
| label by ID | `~123`<br>`[label:123]` | `namespace/project~123`<br>`[label:namespace/project/123]` | `project~123`<br>`[label:project/123]` |
| one-word label by name | `~bug`<br>`[label:bug]` | `namespace/project~bug`<br>`[label:namespace/project/bug]` | `project~bug`<br>`[label:project/bug]` |
| multi-word label by name | `~"feature request"`<br>`[label:feature request]` (when no escaping needed)<br>`[label:"feature request"]` (can optionally always escape) | `namespace/project~"feature request"`<br>`[label:namespace/project/"feature request"]` | `project~"feature request"`<br>`[label:project/"feature request"]` |
| scoped label by name | `~"priority::high"`<br>`[label:"priority::high"]` | `namespace/project~"priority::high"`<br>`[label:namespace/project/"priority::high"]` | `project~"priority::high"`<br>`[label:project/"priority::high"]` |
| project milestone by ID | `%123`<br>`[milestone:123]` | `namespace/project%123`<br>`[milestone:namespace/project/123]` | `project%123`<br>`[milestone:project/123]` |
| one-word milestone by name | `%v1.23`<br>`[milestone:v1.23]` | `namespace/project%v1.23`<br>`[milestone:namespace/project/v1.23]` | `project%v1.23`<br>`[milestone:project/v1.23]` |
| multi-word milestone by name | `%"release candidate"`<br>`[milestone:"release candidate"]` | `namespace/project%"release candidate"`<br>`[milestone:namespace/project/"release candidate"]` | `project%"release candidate"`<br>`[milestone:project/"release candidate"]` |
| specific commit | `9ba12248`<br>`[commit:9ba12248]` | `namespace/project@9ba12248`<br>`[commit:namespace/project/9ba12248]` | `project@9ba12248`<br>`[commit:project/9ba12248]` |
| commit range comparison | `9ba12248...b19a04f5`<br>`[commit:9ba12248...b19a04f5]` | `namespace/project@9ba12248...b19a04f5`<br>`[commit:namespace/project/9ba12248...b19a04f5]` | `project@9ba12248...b19a04f5`<br>`[commit:project/9ba12248...b19a04f5]` |
| repository file references | `[README](doc/README)` | | |
| repository file line references | `[README](doc/README#L13)` | | |
| [alert](../operations/incident_management/alerts.md) | `^alert#123` (to be deprecated?)<br>`[alert:123]` | `namespace/project#123`<br>`[alert:namespace/project/123]` | `project#123`<br>`[alert:project#123]` |
| vulnerability (proposed) | `[vulnerability:123]` | `[vulnerability:namespace/project/123]` | `[vulnerability:project/123]` |
| feature flag references | `[feature_flag:1234]` | `[feature_flag:namespace/project/123]` | `[feature_flag:project/123]` |
### Further details
<!-- Include use cases, benefits, goals, or any other details that will help us understand the problem better. -->
### Permissions and Security
<!-- What permissions are required to perform the described actions? Are they consistent with the existing permissions as documented for users, groups, and projects as appropriate? Is the proposed behavior consistent between the UI, API, and other access methods (e.g. email replies)?-->
### Documentation
- [discussion](https://gitlab.com/gitlab-org/gitlab/-/issues/217614#note_439233250)
* Add all known Documentation Requirements in this section. See https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html#documentation-requirements
* If this feature requires changing permissions, update the permissions document. See https://docs.gitlab.com/ee/user/permissions.html -->
### Availability & Testing
<!-- This section needs to be retained and filled in during the workflow planning breakdown phase of this feature proposal, if not earlier.
What risks does this change pose to our availability? How might it affect the quality of the product? What additional test coverage or changes to tests will be needed? Will it require cross-browser testing?
Please list the test areas (unit, integration and end-to-end) that needs to be added or updated to ensure that this feature will work as intended. Please use the list below as guidance.
* Unit test changes
* Integration test changes
* End-to-end test change
See the test engineering planning process and reach out to your counterpart Software Engineer in Test for assistance: https://about.gitlab.com/handbook/engineering/quality/test-engineering/#test-planning -->
### What does success look like, and how can we measure that?
<!-- Define both the success metrics and acceptance criteria. Note that success metrics indicate the desired business outcomes, while acceptance criteria indicate when the solution is working correctly. If there is no way to measure success, link to an issue that will implement a way to measure this. -->
### What is the type of buyer?
<!-- What is the buyer persona for this feature? See https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/buyer-persona/
In which enterprise tier should this feature go? See https://about.gitlab.com/handbook/product/pricing/#four-tiers -->
### Is this a cross-stage feature?
Yes, this affects every stage that wants to have easily referenced objects.
### Links / references
epic