Skip to content
Français
Try it

Git repositories

Each space maps to one branch of a Git repository: GitHub, GitLab, Gitea or any Git server. This repository is the source of truth: Synaptane commits and pushes its changes to it, and fetches the changes made elsewhere.

content/ visible: wiki, search, MCP
.synaptane/inbox/ items waiting to be tidied up
.synaptane/vocation.md the space's purpose (optional)
.synaptane/prompts/tidy.md tidy-up instructions (optional)

The former name of the instructions file, .synaptane/prompts/rangement.md, is still read when it is the only one; the first save from Synaptane replaces it with tidy.md.

The purpose and the instructions are edited in Settings → Purpose or with a push (see the tidy-up).

On the first sync, Synaptane creates what is missing:

  • content/README.md, if content/ does not exist;
  • .synaptane/inbox/.

The rest of the repository is ignored.

When creating a space (New space, organization admin), choose Create the repository for me on GitHub or GitLab. Synaptane creates a private, empty repository, connects the space to it, and prepares it on the first sync: content/README.md and .synaptane/inbox/ in a first commit, on the branch entered (main by default), which becomes the repository’s default branch. Steps 1 and 2 below are then done for you.

  • Git provider: GitHub (github.com) or GitLab: gitlab.com, or a self-hosted GitLab (its address, in https://).
  • Owner: a GitHub organization, or a GitLab group or subgroup (acme/team). Empty: the account the token belongs to.
  • Repository name: empty, the space’s identifier.
  • Access token: a token that can create the repository (see below). It serves this creation only: it is never saved, and never appears in the logs, the audit log or an API answer.

What Synaptane keeps is limited to the new repository. The token that creates repositories can do far more than the sync needs, so it is not kept:

  • GitHub: an SSH deploy key with write access, generated by Synaptane and registered on the repository (title Synaptane (<your host>)). The SSH keys of github.com are read from GitHub’s API over HTTPS (api.github.com/meta): there is nothing to compare by hand. If GitHub changes them, the sync refused by the host key check reads them again from the same API, saves them and tries once more (audit log: GitHub SSH host keys updated); keys seen over SSH are never trusted as such. This applies to every SSH access to github.com, including a deploy key and host keys entered by hand: the host keys you pasted are then replaced by the ones GitHub’s API publishes. The server must reach github.com on SSH port 22.
  • GitLab: a project access token named Synaptane, with the read_repository and write_repository scopes and the Maintainer role (GitLab protects the default branch on the first push), valid for the longest the instance allows: 365 days by default. Its expiry date is kept with it, and Synaptane warns before it comes (see Token expiry): create a new one then on GitLab (Settings → Access tokens) and enter it in Repository access (step 2). A deploy key is not used on GitLab: it cannot push to the protected default branch without an extra branch rule.

GitHub: a fine-grained personal access token (Settings → Developer settings → Personal access tokens → Fine-grained tokens):

  • Resource owner: your account, or the organization that will own the repository. The organization must allow fine-grained tokens; if it requires approval, the token only works once an organization owner has approved it;
  • Repository access: All repositories (the repository does not exist yet, so it cannot be selected);
  • Repository permissions: Administration, read and write: it creates the repository and registers its deploy key. GitHub adds Metadata (read-only) by itself.

A classic token with the repo scope also works, but it opens all your repositories: prefer a fine-grained token with a short expiry, and delete it once the space is created.

GitLab: a personal access token (User settings → Personal access tokens) with the api scope, which the project API requires, from an account whose role allows creating projects in the group (see the group’s settings, under Permissions and group features). Synaptane then creates the project access token with this same token: since a token cannot get a role higher than its creator’s, the account needs at least the Maintainer role on the new project. A short expiry is enough, since Synaptane does not keep it.

On GitLab.com, project access tokens require a Premium or Ultimate subscription. Synaptane reads the plan of the namespace first: on the free plan, it refuses before creating anything. Create the repository yourself on GitLab, then choose Use an existing repository and prepare its access as in step 1. On a self-hosted GitLab, project access tokens are available in every edition, and the plan is not checked.

Nothing is created if the token is refused (invalid, expired or revoked) or lacks the rights, if the owner or the namespace does not exist, if the name is already taken, if the provider cannot be reached, answers too slowly or limits the number of requests. Each call to the provider is abandoned after 20 seconds, name resolution, connection and whole answer included, and the whole creation after 60 seconds. An account creates one repository at a time (a second request meanwhile is refused). A TLS certificate that is refused (expired, self-signed, for another name) is reported as such: for a self-hosted GitLab with a private certificate authority, add it to the server’s trusted authorities (SSL_CERT_FILE). The message says which.

If the repository was created but its access could not be set up, the space is still created on it, and the message gives the repository’s address (if the space itself could not be created, the message and the server log give that address too): enter its credentials in Settings → Git repository → Repository access (step 2). Synaptane never deletes a repository on the provider: delete it there if you no longer want it.

The audit log records Git repository created by Synaptane (space.repository_created): the provider, the host and path of the repository, and the kind of access kept. Never the token.

Its address must use https://, without credentials. For an organization admin, it must be a public address: as for webhooks, Synaptane resolves the name once, refuses private, loopback and link-local addresses, then connects to the address it checked. Only the super admin can connect a GitLab of the local network (in development, the allow_private_webhooks option also lifts this restriction). Redirects are never followed: the token stays with the address entered.

With the REST API: create_repository in POST /organizations/{org}/spaces (see the API reference).

GitHub, over HTTPS: create a fine-grained token limited to the repository, with the Contents permission set to read and write.

GitLab, over HTTPS: create a project access token (Settings → Access tokens) with the read_repository and write_repository scopes, and the role:

  • Maintainer if the branch is protected, which is the case for main by default;
  • Developer is enough if the branch is not protected, or if Developers are allowed to push to it.

The Guest role, sometimes offered by default, cannot read the code of a private project: the sync then fails with “You are not allowed to download code” (403). The username can be left empty: GitLab accepts any name with a project token.

SSH (any Git host): create a dedicated deploy key, with write access:

Terminal window
ssh-keygen -t ed25519 -N "" -C synaptane -f synaptane-deploy
# Add synaptane-deploy.pub to the Git host (Deploy keys, "Allow write access"),
# paste synaptane-deploy into Synaptane.

Changing the repository URL removes the saved credentials: they are never sent to any repository other than the one they were entered for.

In the space’s Settings → Git repository (organization admin):

  1. Repository address: repository URL and branch.
    • HTTPS: https://github.com/acme/brain.git.
    • SSH: git@github.com:acme/brain.git or ssh://git@host:2222/acme/brain.git.
    • Never put credentials in the URL.
  2. Repository access: paste the token, or the private key.
    • Over SSH, Read the SSH server keys offers the host keys with their fingerprints. Compare them with the ones published by the Git host (GitHub publishes them in its “SSH key fingerprints” documentation) before saving.

Saving the credentials starts a sync. The Status block then shows the state: up to date, error (with Git’s message) or in conflict.

Secrets are encrypted with the master key and never shown again. They never appear on Git’s command line or in its configuration.

An HTTPS access token stops working on its expiry date, and the sync then fails. Synaptane knows this date:

  • for the GitLab project access token it created itself (365 days by default);

  • for a token saved by hand in Repository access (web, or PUT …/git/credentials of the REST API), when the provider gives it. Synaptane asks once, as it saves the token:

    • GitHub (github.com): the GitHub-Authentication-Token-Expiration header of an answer of its API (GET api.github.com/rate_limit, which uses up no request quota), given for fine-grained tokens and classic tokens that expire;
    • any other HTTPS host, taken for a GitLab: GET /api/v4/personal_access_tokens/self, which gives expires_at for personal, group and project access tokens. GitLab may refuse it to a token without the read_api or api scope (a project token with only read_repository and write_repository): the date then stays unknown.

    The call goes to the repository’s own host only (for GitHub, its API), which receives the token for the sync anyway, with the protections of the repository creation: abandoned after 10 seconds, never redirected, and for a self-hosted host, a public address only (resolved once, then connected to the address checked), except for the super admin. A repository at an IP address or at a host name that is not plain ASCII is not asked (two IDNA versions can turn such a name into two different domains), nor is a password that is not plain ASCII. Nothing else is read from the answer, and the date is kept with the token, encrypted: no migration. When the date is unknown (no expiry, refused, another Git host, unreachable), the token is saved all the same, without warning. An SSH key does not expire.

    A token with an invisible or control character (a zero-width space, a tab or a no-break space pasted with it) is refused with “Invalid access token”. Spaces and accented letters stay allowed inside: the field also takes a password (Gitea, Bitbucket Server).

Once the date is known:

  • Settings → Git repository → Repository access shows it, as a warning within 30 days, as a problem once it has passed;
  • the organization’s admins get an alert (email and Alerts in the audit log, space.alert webhook) 30 days, 7 days and 1 day before, then on the day it expires, once per step: the worker checks every hour, and a worker stopped for a while only sends the step reached. A new token, with another date, starts over. If every email of a step fails (mail server down), the next hourly check sends them again, without a second audit event or webhook. The audit log and the system alerts show the expiry date;
  • Administration > Health has a Git access tokens line: warning when a token expires within 30 days, problem when one has expired, with a link to each space’s Git page;
  • a sync refused for authentication after this date says that the token expired, and when. Only to the organization’s admins, like the rest of the repository access: the space’s other readers see the general authentication message.

To renew it: create a new token on the provider (GitLab: Settings → Access tokens, read_repository and write_repository scopes, Maintainer role; GitHub: a fine-grained token limited to the repository, Contents read and write), then paste it in Repository access. GitLab gives a day, in UTC: its token stops working on that date, so the day counts as expired. GitHub gives the moment: on the last day, before that hour, the token “expires today”, then has expired.

Without a webhook, Synaptane checks the repository every poll_minutes, 5 minutes by default. With a webhook, each push triggers an immediate sync.

  1. Webhook block → Generate the secret.
  2. On the Git host:
    • GitHub: Settings → Webhooks → Add webhook. Enter the URL shown, the content type application/json, the secret, and the Just the push event event.
    • GitLab: Settings → Webhooks → Add new webhook. Enter the URL and the Secret token, check only Push events, and leave SSL verification on. Test → Push events must answer 202.
    • Gitea: same as GitHub.

The webhook URL is built from public_url, which must be reachable by the Git host.

  • It fetches the branch, then merges in what is new: fast-forward, or a merge if Synaptane also has unpushed commits.
  • It pushes Synaptane’s commits right away, never forcing. If the repository moved on in the meantime, it fetches, merges again and pushes again (three rounds at most).
  • Pages changed by commits made outside Synaptane show up in the inbox (change items, computed from the history: nothing is written to the repository). The nightly tidy-up folds them in: links, location, consistency. On the first clone, the existing history is not treated as new.
  • It records readable commits:
    • the author is the person acting, or for automatic actions Synaptane (space set-up, merges), Synaptane tidy-up (tidy-up runs), Synaptane routine (<name>) (routines) or Synaptane recovery (local changes reapplied after a history change);
    • the committer is Synaptane <synaptane@public-host>;
    • subjects are in English: Inbox: … (notes), Tidy-up: …, Routine "<name>": …, Synaptane: initialize space, Synaptane: merge remote changes… Histories written by older versions keep their French names and subjects (Synaptane – rangement, Rangement : …, Inbox : …), still recognized: see Repository format.

Nothing local is lost when the history changes under Synaptane:

  • URL or branch changed (moving to another Git host, corrected repository): the local copy is rebuilt from the new repository, then the pages and notes changed locally are reapplied to it and pushed.
  • Remote history rewritten (force-push, a leaked secret purged, branch recreated): Synaptane adopts the new history; the removed commits do not come back. Only the changes made in Synaptane since the last sync are reapplied.

In both cases, the old local branch is first saved in full in a Git bundle (data/recuperation/<space id>/<date>.bundle, which git clone can restore). A file changed on both sides is not reapplied: it stays in the bundle, and the audit log (space.local_changes_recovered) lists the files concerned.

Changing only the address of the same repository (switching from HTTPS to SSH, a new domain name for the Git host) loses nothing for the tidy-up: changed pages waiting to be tidied and pages left aside with a reason stay in the inbox. They are only recomputed if the new repository does not contain the history already reviewed.

A local copy left half-done by a killed process (index lock, interrupted merge) is repaired automatically on the next operation.

A Git host that stops responding never blocks Synaptane: web, REST and MCP writes and the tidy-up carry on with the local copy, and are sent on the next sync. All exchanges with the Git host (clone, fetch, push) run without holding the local copy; only the local steps (merge, commit) reserve it, for a few moments.

Timeouts:

  • HTTPS: a transfer below 1,000 bytes per second for 60 seconds is abandoned;
  • SSH: the connection is abandoned after 20 seconds, and the session is cut after one minute without an answer from the server;
  • overall timeout for one exchange: 5 minutes (git_timeout, in seconds, see Configuration). Only raise it if the first clone of a very large repository does not complete.

An interrupted exchange puts the space in error, with Git’s message; what was already fetched and merged is kept. The sync is retried automatically.

The HTTPS token is only given to the host of the repository address: if the Git host redirects to another server, that server does not receive it.

When the same file was changed on both sides:

  • the space goes into conflict and nothing is pushed;
  • the Conflicts to resolve block lists the files, and for each one you keep either Synaptane’s version or the remote repository’s;
  • the resolution produces a merge commit, in the name of the person who decided, stating which version was kept for each file. The other version stays in the Git history.

The sync runs in a separate process:

Terminal window
uv run synaptane worker

It must run at all times next to synaptane serve. Several workers can run at the same time safely: each job is taken only once, and each space is handled by only one worker at a time. A network error is retried automatically, 5 times at most. An authentication error is shown as is on the space page (with the expiry date when the saved token has expired).