Products in several repositories
Some products keep their code in several repositories: an API and its web client, a service and its SDKs, a library and the app that uses it. A feature can need a change in each, and a bug can have its fix in one and its test in another. Linked repositories let one kōjō session work on all of them: the session’s own repository stays the workspace, the other repositories of the product are cloned next to it, and every repository that changed gets a pull request of its own.
Linked repositories are not reference repositories. A reference repository is read-only, named by one request and never published. A linked repository is configured once for a repository, may be changed, and is published.
When to use it
- A feature spans repositories: an endpoint in the API and the page that calls it.
- A fix and its test live apart: the bug is in a library, the test that shows it is in the app.
- Generated or hand-written clients follow a server: a field added to the API and to each SDK in one change.
When the other repository only has to be read (a client checked against its server, a change ported from a sibling SDK), use a reference repository instead.
Configure the links
A repository’s entry in the repos object lists its linked repositories under linked, as forge/owner/name. Every session on that repository gets them. An operator sets them, in the dashboard (Settings, Repositories, Configure, Linked repositories), with kojo config apply, or through the API.
version: 1
objects:
- scope: org
object: repos
content:
repos:
github/acme/api:
enabled: true
linked: [github/acme/web, github/acme/sdk-go]
github/acme/web:
enabled: true
linked: [github/acme/api]
github/acme/sdk-go:
enabled: true
In this example a session on github/acme/api gets the web client and the Go SDK, a session on github/acme/web gets the API, and a session on github/acme/sdk-go gets nothing: links go one way.
- Each entry is
forge/owner/name, not the repository itself, listed once, and at most eight per repository. - Each linked repository is cloned at
.kojo/linked/<name>, where<name>is the last segment of its path. Two linked repositories with the same last segment (github/acme/webandgitlab/acme/web, compared without case) are refused. - A linked repository must be enabled, and so its default branch is protected like any enabled repository’s. A link to a repository that is not enabled stays in the object but is left out of every session, and
kojo doctorfails its “linked repositories” check for it. - A repository’s own
.factory/factory.yamlcannot add links: a repository cannot give itself access to others.
Name more for one request
A request can add linked repositories of its own. The request input linked.<name> holds one, and <name> must be its last path segment.
kojo run --repo github/acme/api --with github/acme/web "add the endpoint and its page". The flag can be repeated.- An API or MCP request carries
"inputs": {"linked.web": "github/acme/web"}.
Only a trusted request may name one (an operator through the CLI, the API, the dashboard or MCP), and the repository must be enabled, on a configured forge, and not the session’s own. A request that names one it may not have is rejected before it is queued.
The workspace
/workspace/ the session's repository
└── .kojo/linked/
├── web/ github/acme/web, at its default branch
└── sdk-go/ github/acme/sdk-go, at its default branch
- Each linked repository is cloned 50 commits deep at its default branch and is a git repository of its own.
- git in the workspace ignores
.kojo/linked/(an entry in.git/info/exclude), and the core leaves the directory out of the diff of the session’s repository whatever is staged. Each linked repository is diffed on its own. - The core clones each one before the first skill runs, the way it clones a reference repository: during the clone the sandbox may reach only that repository’s git host, with the read-only clone credential its forge adapter issues for that repository; the skill’s policy is applied again afterwards.
- When a session uses a second sandbox image, the linked repositories are copied over with the workspace.
- A repository that tracks files under
.kojo/linked/, or has a symbolic link at.kojo, cannot be worked on with linked repositories: the session fails when it prepares the workspace.
Who may write where
Writing to a linked repository needs what writing to the session’s own repository needs, judged for that repository. A linked repository may be changed when all of these hold:
| Condition | Otherwise |
|---|---|
| The request is trusted | Every linked repository is read-only |
For a request from a forge (a mention, an automatic trigger, an on_merge follow-up): the requester’s account has the linked repository’s trigger_permission on it |
Read-only. An account on another forge than the linked repository’s cannot be checked: read-only, and not cloned at all when the repository is private. |
| For any other request (the CLI, the API, the dashboard, MCP, chat, a schedule): it comes from the operator role, which holds for every repository. A schedule counts as an operator’s. | Not trusted: read-only |
| The linked repository is not public while the session’s own repository is private: work made from a private repository is not published where anyone can read it | Read-only |
A read-only linked repository is cloned and can be read. The file tools refuse to write in it, a change made there by other means fails the goal critic, and nothing of it is ever published. Each subagent is told which linked repositories are read-only and why.
Some linked repositories are not cloned at all, without failing the session: a private one when the session’s own repository is public (a dry run is exempt, it publishes nothing), a private one the requester’s forge account cannot read, one that is not enabled, and one whose forge is not configured. The answer to the request lists them with the reason, and the audit log has a linked.skip entry for each.
What skills see
- The orchestrator and every subagent are told, in their instructions, which linked repositories exist, where they are, and whether each may be changed.
read_file,write_fileandedit_filetake paths under.kojo/linked/<name>/.list_filesandsearchgiven a directory or path there list and search that repository with its own git. A linked repository’s.gitcannot be written with the file tools.execand the goal checks have the environment variableKOJO_LINKED, the linked repositories in the workspace asname=directorypairs:web=.kojo/linked/web sdk-go=.kojo/linked/sdk-go. It is a value, never shell syntax: read it in a command (for p in $KOJO_LINKED; do ...; done).git_diffshows the change of every repository; the paths of a linked repository start with.kojo/linked/<name>/.
Goals and checks
The goal critic judges what one skill run changed in every repository, each measured from its state when the run started. The constraints apply to the change as a whole:
max_changed_linesis the sum over all repositories.forbidden_pathsandrequired_pathsmatch each changed file by its path in its own repository (src/api.ts) and by its path in the workspace (.kojo/linked/web/src/api.ts), so a recorded value such as${REPRO_TEST}names a file of a linked repository by its workspace path.no_changescovers the linked repositories too.- A change in a read-only linked repository fails, whatever the skill allows.
Checks run at the workspace root, as always. A recorded command can go into a linked repository:
# goals.yaml of a skill that changes the API and its web client
max_attempts: 3
checks:
- name: api tests
run: make test
- name: web tests
run: cd .kojo/linked/web && npm test
- name: the reproduction now passes
run: ${TEST_CMD}
skip_if_unset: true
constraints:
max_changed_lines: 600
forbidden_paths: ["${REPRO_TEST}"]
The judge reads one diff of every repository, with workspace paths. The bounds on what one session publishes (500 files, 16 MiB) hold for all repositories together.
What gets published
sequenceDiagram
participant R as Requester
participant C as Core
participant F as Forge
participant S as Sandbox
R->>C: mention on an issue of github/acme/api
C->>F: the requester's permission on api and on web
C->>S: clone api at /workspace, web at .kojo/linked/web
Note over S: the subagent changes both, the critic checks both
C->>S: diff api, diff web, each on its own
C->>F: branch, commit and pull request on api
C->>F: branch, commit and pull request on web, linking api's
C->>F: api's pull request description, written again with web's link
C->>R: the answer, with both pull requests
- One pull request per repository that changed, on a
kojo/<slug>-<id>branch of the same name in each, through that repository’s forge API. The session’s own repository is first; its pull request goes where it always would. A linked repository’s goes against its default branch. Each linked repository’s pull request comes from its own forge, so the repositories of one product can be on different forges. - Each pull request links the others in a “Part of a change across N repositories” section of its description. A description is written before the pull requests opened after it exist, so those are named by their branch at first. Once all are open, kōjō writes the description of each earlier pull request again, with links in place of the branch names. If the forge refuses that edit, a comment on the pull request lists the links instead, and the failure is logged and shown as a failed step of the session.
- The issue. No single pull request of the change completes it, so none closes it: the pull request on the session’s own repository says
Refs #Ninstead ofFixes #N, and the others sayRefs owner/name#N. - The answer to the request, in chat or on the issue, names every pull request.
kojo runprints them all, and the session screen of the dashboard lists them with their repositories. - Where each changed line came from is worked out per repository: each writable linked repository has snapshots of its own, in its own
.git, and each pull request’s “Where the changes came from” section lists the files of its own repository, by their paths in it. In the dashboard’s diff a linked repository’s files keep their.kojo/linked/<name>/paths, each block with the step that wrote it. - The session result keeps
pr_url,pr_numberandbranchfor the primary pull request (the session’s own repository’s, or the first linked one’s when only linked repositories changed) and lists all of them underpull_requests. - Each pull request is recorded with its repository, so a review on it teaches lessons to that repository, and the merge rate and human-edit rate count it.
The merge policy makes one decision for all the pull requests of a change:
- The mode is the most careful one among the repositories that changed:
draft_only, thenask, thenauto_merge. One linked repository ondraft_onlymakes every pull request a draft. - Under
ask, one approval in chat opens every pull request. Without an answer by the question’s deadline, every pull request is opened as a draft. - kōjō never merges a change that reaches beyond the session’s own repository. Merges cannot be made atomic across repositories, so a partial merge could break the product. Such a change has a risk rule of its own (0.5) and is at most opened ready for review.
Follow-ups on one pull request of the change
A mention on one of the change’s pull requests, or a failed check on it where its repository opts in, starts a follow-up on that pull request alone:
- It changes only that pull request. The session works on that repository, on the pull request’s branch, and commits only there. The requester’s permission was checked on that repository, the branch that may move under the session is that one, and the merge policy decides on that one pull request.
- The rest of the change is in view, read-only. The repositories that repository links are cloned at
.kojo/linked/<name>as always, but read-only, and where the change has an open pull request in one of them, at that pull request’s branch instead of the default branch, so the subagent sees the change as a whole. The file tools refuse to write there, and the goal critic fails a change in one. Links go one way, so a follow-up on the web client’s pull request sees only the web client when only the API links it. - It is never merged. The pull request is still part of a change across repositories: the risk rule of 0.5 applies, and the decision is at most a pull request ready for review.
- A change in another repository is asked for there. When the review also needs a change in another repository, mention kōjō on that repository’s pull request too.
Doctor
kojo doctor checks every enabled repository that has links: “linked repositories <id>” fails when a linked repository is not enabled, since sessions leave it out. Every enabled repository, linked or not, has its own branch protection check.