Repository navigation
Description
Context: the multi-repo project connections in Paca-AI/paca#648, and the follow-up to Paca-AI/paca-plugins#34. Related core proposal: Paca-AI/paca#649. Text-only proposal against feature/update-git-workflow, for agreement before code.
Problem
Once a Paca project links several GitLab repositories, users will often add one project access token per repository, or a group access token. Each kind reaches different projects. The provider doesn't tell them apart: identityRecord.Bot is true for both project and group tokens (accessTokenBotRe in gitlab.go), and nothing records what a token covers.
- A public repository can bind to the wrong connection.
ResolveRepositorytakes the first candidate that canGET /projects/:path. A public project answers any token (see the comment inspi_provider.go).- So
acme/api(public) can be bound to the project token ofacme/ui. The link succeeds and reads work, but pushes, comments andEnsureWebhookfail later. MintCredentialonly refuses writes when GitLab reports0 < access_level < Developer, so a non-member (level 0) still gets a credential.
- Users can't see what a connection covers. The connection list shows only the bot handle (
project_123_bot_abc). - Unhelpful error. When no connection covers a repo, the error is "no identity can see acme/api", with no hint that another connection or a group token is needed.
Proposal (provider only, no SDK change)
1. Detect the token type and reach at setup
In CompleteIdentitySetup, after validateToken, classify the token from the bot user name:
| Username | Type | Reach | Lookup |
|---|---|---|---|
project_<id>_bot… |
project | that project | GET /projects/<id> → path_with_namespace |
group_<id>_bot… |
group | the group and its subgroups | GET /groups/<id> → full_path |
| anything else | personal | the user's memberships | none |
- Store
TokenType,ResourceIDandResourcePathonidentityRecord, with new columns ongitlab_identities(a new migration). - If the lookup fails (for example a token without
read_apion the group), keep the type and leave the path empty.
2. Show the reach
identityOf sets Identity.DisplayName to, for example:
- "Project token · acme/ui";
- "Group token · acme/frontend";
- "Personal token · alice".
Core already shows the display name in Project Settings → Git → Connections.
3. Filter candidates in ResolveRepository
Before any API call:
- a project token is skipped unless
ResourceIDequals the project id (orResourcePathequals the path, when the input is a path); - a group token is skipped unless the repo path is
ResourcePathor below it.
After GET /projects/:path, require accessLevel() >= Developer (30). Otherwise move to the next candidate. A token that can only read a public project never wins.
ListRepositories already uses membership=true, so it lists only what the token is a member of. No change is needed there.
4. Tighten MintCredential
For AccessWrite, also refuse level 0 (non-member) instead of only 0 < level < Developer.
5. Clear errors
When every candidate is skipped, return CodeForbidden / CodeNotFound with a message that names what each connection covers, for example: "The connected project token covers only acme/ui. Add a connection for acme/api or use a group access token."
Migration
- Existing identities have no type stored. The migration leaves the columns empty.
- The provider classifies them lazily, from the stored username, the first time it loads them, and saves the result.
- No user action is needed.
Tests
- Classification of each username form.
ResolveRepository:- a project token skipped for another repo;
- a group token covering a subgroup;
- a public repo not bound to a non-member token;
- the ordering when several candidates qualify.
MintCredentialrefusing a write at level 0.- The display name for each kind.
- These extend
spi_fakegitlab_test.gowithproject_<id>_botandgroup_<id>_botusers,/groups/:id, andpermissionson/projects/:id.
Open question
Should core show a structured "reach" instead of relying on DisplayName? That would need an optional field on gitprovider.Identity. I'd keep that out of this change.
Activity
pikann commentedon Oct 28, 2026
Hi @gorlix ,
Thanks for the detailed proposal!
Would you like to submit a PR for this? If so, please let me know. Otherwise, I’d be happy to jump in and take care of it.
gorlix commentedon Oct 28, 2026
hello @pikann
Absolutely;
I just wanted to get your confirmation that I’ve understood everything correctly.
gorlix commentedon Oct 28, 2026
Hi @pikann,
Thanks, that's a fair point, and I agree. A task that spans backend and frontend shouldn't be tied to one repo through its ID.
Keeping PROJ-N as the only identifier is the better model, so I'm withdrawing the repo-key part of the proposal.
Two smaller things are still worth doing:
hyphen. If anyone writes a 3-part string in a branch or title (from habit or from another tool's convention), it can link to
nothing, or to a task in a project whose prefix happens to be UI. The fix: only accept a match that isn't preceded by -, with tests. No schema or API change.
pikann commentedon Oct 28, 2026
Yes, it's a good suggestion. A description for the repository will also be helpful for the agent to detect which repository to use