Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Git sync

Git sync exports a project’s files to a branch of a git repository on GitHub, GitLab or any host that accepts SSH deploy keys or HTTPS access tokens. Agrafe pushes to the repository; it reads from it only when you import its files, on connecting or to resolve a divergence.

The settings are at the bottom of the Package pane (the Package button at the bottom of the sidebar), in the Git sync section. The server must have git sync enabled; if it is not, connecting answers “git sync is not available on this server”, followed by the reason in brackets (for example git: spawn failed: No such file or directory (os error 2); ssh: ok when the host has no git package).

Git sync requires the project owner’s plan to be Pro or Enterprise (a collaborator’s plan does not count). After a downgrade the sync is paused, with the connection and its history kept; it resumes on its own once the owner upgrades again.

How it works

  • A branch owned by Agrafe. Agrafe pushes to one branch, agrafe by default. Others should not commit to it: people merge it into their own branches through pull or merge requests. Commits by others that touch only files Agrafe does not hold (a README.md, CI files), or .dlf files Agrafe left unchanged, are merged automatically; overlapping changes stop the sync as Diverged.
  • Autosaves. While you edit, Agrafe records snapshots of the project locally, after 30 seconds without a save or at the latest 5 minutes after the first unsaved change. Autosaves are never pushed.
  • Checkpoints. A checkpoint squashes the autosaves into one commit with your message and pushes it. The branch history is one commit per checkpoint.
  • Releases. Creating a release adds an annotated tag v<version> and pushes it when the sync can push. A failed tag never fails the release; the reason shows as the last error.

What the repository contains

Under the connection’s path prefix (the repository root by default):

  • every project file at its path, folders included (models/person.dlf is in a models folder), package.dlf included, except the files .syncignore lists;
  • the import locks, one folder .dolfin/imports/<import>/ per locked import, the same files as Export as zip writes (see Import locks on disk).

Every other file stays as it is: everything outside the path prefix, and under it everything Agrafe neither imports nor holds as a project file (a LICENSE, CI files, a .dlf the import skipped), and every file .syncignore lists. Deleting a project file other than .dlf, .md or Turtle in Agrafe does not delete it from the repository.

Keeping files out of the repository (.syncignore)

A file .syncignore at the project root lists the project files git sync leaves out, for example the graph layout .dolfin-layout.json. One pattern per line, with the .gitignore syntax: blank lines and lines starting with # are skipped, * and ? stay within a folder, ** crosses folders, a trailing / means a folder, a leading / anchors the pattern to the root, and ! takes a file back. A pattern without / matches the file name in any folder. Paths are relative to the path prefix.

# Agrafe-only files
.dolfin-layout.json
drafts/
  • Never committed. Checkpoints, autosaves, releases and auto-merges leave the matching files out. A copy already in the repository stays as it is: it is not deleted, nor updated. Delete it with git if it must go.
  • Never pulled. An import, Take remote version and an auto-merge never overwrite nor delete the Agrafe copy of a matching file, and do not list it as skipped. The project’s own .syncignore always applies: the repository’s .syncignore is never imported.
  • Never pending. Edits of matching files do not count as changes in the Git panel, so they never make the sync look dirty.
  • Version history still applies. Versions still lists and restores the matching files: only git leaves them out. While connected, the History tab lists every version of these files under Not synced, with the usual diff and Restore.
  • .syncignore itself is always synced, including in release commits, even if a pattern matches it (*).
  • Only the root .syncignore counts. A .syncignore in a folder is an ordinary file.
  • Import locks are kept or synced a whole folder at a time. The path .dolfin/imports/<import>/lock.json decides for its folder: *.json or .dolfin/imports/<import>/ keeps that lock local, *.ttl alone does not split a lock.
  • The MCP tool get_git_status lists the matching project files under ignored.
  • Not supported: escaped trailing spaces and \#.

Don’t sync from the Git panel: the Connect form and the Checkpoint… dialog list the project files not in git yet, each with a Don’t sync box. A ticked file gets an exact line in .syncignore (/name for a root file) before the commit is built, so it is left out of that very commit; .dolfin-layout.json is ticked the first time it shows up. Not synced (N) lists the files .syncignore already keeps out: untick a file listed by an exact line to remove that line. A file matched by a wider pattern (*.json) shows that pattern read-only: edit .syncignore to change it.

A clone of the branch therefore passes radeau check offline, as long as every import is locked.

Connecting a repository

Only the project owner can connect. Choose SSH (deploy key) or HTTPS (access token) first; the fields follow the choice. Then fill in:

FieldContent
Remote URLThe repository’s SSH URL, such as git@github.com:org/repo.git, or its HTTPS URL, such as https://gitlab.com/org/repo.git. An HTTPS URL must not contain a user or a token, nor a query or fragment.
Access tokenHTTPS only, required. A password field. See Creating a token for HTTPS. The field’s hint reads “GitLab: project or deploy token with write_repository; GitHub: fine-grained token with Contents read/write”.
Username (optional)HTTPS only. Default oauth2.
SSH keySSH only. Generate a new key (default), optionally with Save as … in my settings to keep it as a named key for other projects; or Use a saved key from your list (name and short fingerprint).
BranchThe branch Agrafe pushes to. Default agrafe.
Path prefixOptional folder of the repository the files go in, such as ontology/hr.

With SSH and a new key, Connect creates a deploy key for this project and shows its public half. The private key is stored encrypted on the server and is never shown. Add the public key on the host as a deploy key with write access. With a saved key, the section shows that key’s public half and says it is likely already on the host: run Test connection first and add the key only if the test fails. A key you have just generated and saved under a name gets the new-key message instead: add it on the host.

HostWhere
GitHubRepository Settings → Deploy keys → Add deploy key. Paste the key and tick Allow write access.
GitLabProject Settings → Repository → Deploy keys → Add new key. Paste the key and tick Grant write permissions to this key.
Other hostsAn SSH deploy key, or the SSH key of a bot account, with push access to this repository only.

Named SSH keys that you can use for several projects are managed in Settings → SSH keys (Account settings). GitHub refuses the same deploy key on two repositories. To reuse one key across repos, add it as the SSH key of a bot/machine account (GitHub), or enable it on each project (GitLab deploy keys can be shared).

GitHub accepts a deploy key on one repository only: a saved key already added to another GitHub repository is rejected. When you pick a saved key for a GitHub remote, the form and the connected section say so, outside the host tabs.

Saved SSH keys

Saved keys belong to you and can be reused across your projects. Agrafe generates them; the private key never leaves the server, and there is no import of an existing private key. A key cannot be deleted while a project uses it. Only you can attach your saved key to a connection.

Changing the key

On a connected SSH project, the owner’s Change key… button switches the connection to another saved key, or generates a new key (optionally saved under a name). Generating asks for confirmation: the old public key stops working on the host, so add the new one there. After either change, run Test connection.

The section opens the instructions of the host it recognises in the URL; the tabs show the others. Copy puts the key on the clipboard.

With HTTPS, Connect stores the token encrypted and creates no deploy key. The connected section shows the transport, “token set” and a Replace token button instead of the deploy key box.

A remote (HTTPS, ssh:// or user@host:path, including user@[IPv6]:path) whose host is localhost (or ends in .localhost) or a loopback, private, link-local, CGNAT, multicast, reserved or documentation IP address is refused when connecting, with “remote host must not be localhost” or “remote host is a private or local address”. A host name is checked again before each push, fetch or test: if it resolves to such an address, the run stops as Remote unreachable with “remote resolves to a private address”. SSH then connects to the address that was checked, so the name is not looked up a second time.

An SSH remote must not contain [ or ] outside a bracketed IPv6 host (“remote URL must not contain ‘[’ or ‘]’ outside an IPv6 host”), so a repository path with brackets (for example repo[1]) cannot be used.

SSH or HTTPS

  • SSH: a deploy key per project, created by Agrafe, or one of your saved keys. The deploy key and host key paragraphs of this page apply to SSH only.
  • HTTPS: an access token that you create on the host and paste.
  • Pick HTTPS when SSH port 22 is blocked, when the host only offers tokens, or when your organisation manages access through tokens.
  • Pick SSH when you prefer a key limited to one repository that you can revoke on the host.

Creating a token for HTTPS

HostTokenUsername
GitLab, project access tokenProject Settings → Access tokens, role Developer or higher, scope write_repository.Any value works; keep the default oauth2.
GitLab, deploy tokenProject Settings → Repository → Deploy tokens, scope write_repository.Must be the deploy token’s username.
GitHubA fine-grained personal access token limited to this one repository, with Repository permissions → Contents: Read and write.Leave the default.

The token is stored encrypted on Agrafe, sealed with the server’s master key. It is never shown again, never written to the audit log, and deleted on Disconnect.

Keep the token in this browser only

With HTTPS, the connect form offers two choices:

  • Store token encrypted on Agrafe (default): background sync, as described above.
  • Keep token in this browser only: Agrafe never stores the token.

What the second choice does:

  • The browser keeps the token in its local storage, under agrafe-git-token:<project id>, and sends it with each git action (test, checkpoint, import, branch switch, overwrite, release tag).
  • The server uses it for that one git run, in memory, and forgets it. It is never written to Agrafe’s database, logs, audit log, backups or error messages.
  • Connecting checks the token against the repository first; a refused token connects nothing.
  • The browser cannot talk to GitHub or GitLab itself: their git endpoints do not allow requests from other websites (no CORS). That is why the token still passes through Agrafe’s server.

The tradeoffs:

  • No background sync. Agrafe pushes only while a browser holding the token has the project open. A checkpoint whose push failed is pushed again from that browser, once the project has been quiet for 30 seconds. Until then the status says Waiting for a browser with the token.
  • Per browser. Another browser, another device, or an editor of the project needs the token too: the section asks for it under Token for this browser. Without it, checkpoints and imports are refused with “token needed from browser”, and a release tag is created but not pushed.
  • Lost when the site’s data is cleared. Enter it again then. Forget token in this browser removes it on purpose.
  • What it protects against. A leak of Agrafe’s database, of a backup, or of the server’s master key does not expose the token.
  • What it does not protect against. A compromised Agrafe server, or a cross-site scripting flaw in Agrafe, can read the browser’s local storage and see every request. Against those, the encrypted copy on the server is actually safer: it never reaches the browser.
  • MCP tools never hold the token: git_checkpoint is refused for such a connection.

To switch later, the owner uses Replace token or where it is kept:

  • To the browser: Agrafe’s copy is deleted, and this browser keeps the token you enter.
  • To Agrafe: the token you enter is sealed on the server, and this browser’s copy is forgotten.

Replacing a token

  • Owner only: Replace token or where it is kept in the connected section asks for the new token and, optionally, a username (blank keeps the current one).
  • Use it before the token expires, or after it was revoked.
  • It does not change the branch or the history, nor the status: run Test connection afterwards.
  • Tokens expire: set a reminder for the expiry date.

Branch warning

If the branch is main or master, the section warns that it looks like the repository’s main branch. Connecting is allowed. Commits made on that branch outside Agrafe are merged automatically when they touch only other files, or .dlf files Agrafe left unchanged (see Merged automatically); any overlap stops the sync as Diverged. Prefer a dedicated branch.

Test connection

Test connection checks that Agrafe can reach the repository with the deploy key or the token (git ls-remote), without pushing. A successful test does not lift Paused or Diverged.

With SSH, the host keys of GitHub and GitLab.com are built in. For any other host, Test connection shows the fingerprint of the host’s key (“Host key of the remote: SHA256:…”). Compare it with the fingerprint your host publishes, then click Trust this host key. Pushes and imports are refused (“host key not confirmed”) until you have. Agrafe scans the host again when you confirm: if it now presents a different key, nothing is recorded and you test again. The recorded key is never replaced, so a host that later presents another key is refused. With HTTPS there is no host key to record.

Importing from the repository

When the connection works and nothing was pushed yet, Test connection also looks at the branch. If it already exists, the section lists what an import would bring before anything is written:

  • the .dlf, .md and Turtle (.ttl, .turtle, .n3) files under the path prefix, in their folders. Each Turtle file that is not yet a Turtle source becomes one after the import, as with Add Turtle source: it is translated, and its .dlf files are added or merged into. If that fails, the import still stands and the message says why;
  • the import locks under .dolfin/imports/ (see Import locks on disk);
  • the skipped entries, each with its reason: files that are not .dlf, .md or Turtle (a LICENSE), files over 5 MiB, names a project file cannot have (such as .hidden.dlf or docs/.hidden.dlf), and content that is not UTF-8 text.

Two buttons follow (owner only):

  • Import into this project, offered only while the project has no file but its package.dlf. The files are written as if you saved them, so each one gets a version in its history; the remote package.dlf replaces the default one.
  • Create a new project from the repository creates a project of yours, named after the repository, imports the branch there and opens it. The connection, with its deploy key or token, moves to the new project: the current project is disconnected, since both cannot push to one branch. Your usual project and file limits apply.

An import is all or nothing: an import lock whose files do not match its lock.json stops it before any file is written. After an import, the branch counts as pushed: the next checkpoint only commits what you change. A checkpoint writes the branch’s whole content, so files that were skipped disappear from it; keep the branch for Agrafe.

If you do not import, the first checkpoint stops as Diverged (the branch has commits Agrafe did not make).

Status

The section shows the status, the remote, the branch, the time of the last push attempt and the last error. A small branch icon next to the project name in the top bar shows the same status, in the status’s colour, with the status, the unpushed changes and the last error in its tooltip. After an automatic merge, the tooltip adds “auto-merged at least N remote commit(s) (range)”. Click it to open the Git sync section. The icon is absent when the project is not connected. It refreshes every minute and after each action.

StatusMeaning
OKThe last push or test succeeded.
Waiting for a deploy keyThe connection has no deploy key (SSH only).
DivergedThe remote branch has commits Agrafe did not make. Pushes stop until you resolve it, see below.
Authentication failedSSH: the host refused the key (missing, read-only or revoked). HTTPS: shown as “Authentication failed: token rejected or lacks write access” (expired, revoked, wrong scope or wrong username).
Remote unreachableThe host could not be reached, or (HTTPS) its TLS certificate was not accepted. Agrafe retries, waiting longer after each failure (up to 15 minutes).
Push rejectedThe host refused the push, for example a protected branch or a server hook.
PausedPushes are paused.

A connection that keeps its token in the browser also shows Waiting for a browser with the token while it has changes or a checkpoint to push and this browser has no token.

After an automatic merge, the Git sync section and the History tab show the notice “Merged at least N remote commits (range): files”, with an Undo auto-merge button (see Undo auto-merge).

Under the table, the section counts the unpushed changes: the files added, modified or deleted since the last pushed checkpoint, and the autosaves taken since. Show files lists them. A checkpoint that was committed but not pushed yet is mentioned too.

When a token expires

  • On the next push or test, the status turns to Authentication failed: token rejected or lacks write access.
  • Test connection fails the same way.
  • Checkpoints are still committed locally; the next checkpoint after Replace token pushes them.

Checkpoint, pause, disconnect

  • Checkpoint… asks for a message (at most 1000 characters), commits and pushes. If nothing changed, nothing is committed. While the sync is paused, waiting for a key or diverged, the checkpoint is committed but not pushed; the next checkpoint pushes it.
  • The History tab of a connected project also has a commit box, above the files changed since the last pushed commit, grouped by file.
  • Pull now looks at the remote branch once and brings its new commits into the project when that is safe: the same cases as an auto-merge (only files Agrafe does not own changed, or owned files you have not edited since the last push). Nothing is pushed; edits not checkpointed yet stay in the project for the next checkpoint. If a checkpoint is still waiting to be pushed, it is pushed instead. When the changes cannot be applied safely, nothing changes and the message says why. At most one pull a minute per project. Agrafe does not look at the remote on its own: without Pull now, remote changes show up at the next checkpoint.
  • Pause stops pushes. Autosaves go on locally. Resume restarts them.
  • Disconnect asks for confirmation, then deletes the connection, its deploy key (SSH) or stored token (HTTPS), and Agrafe’s copy of the repository. A saved key stays in your settings. The repository on the host is not changed: remove the deploy key there yourself, or revoke the token.

Resolving a divergence

Merged automatically

When a push finds commits on the remote branch that Agrafe did not make, Agrafe first tries to merge them, in two cases:

  • Case 1: the remote changed only files outside the project’s files and import locks (a README.md, CI files, files outside the path prefix). Agrafe commits its checkpoint on top of the remote branch; the project is unchanged.
  • Case 2: the remote changed .dlf, .md or Turtle files or import locks that Agrafe left unchanged since its last push. Their remote content is written into the project, each as a new version tagged via: git remote <sha>. The project must have no errors before, and none after the merge; warnings and a failed fact check are fine, as in the Problems panel.

It does not merge, and stops as Diverged with a last error ending in not merged automatically: <reason>, when:

  • the same file changed on both sides, or was deleted on one side and edited on the other;
  • the remote added a new .dlf file;
  • the project has errors before the merge, or would have errors after it;
  • an import lock changed on both sides;
  • the remote history was rewritten (a force push), or is more than about 670 commits ahead;
  • the fetch hits the size limits (see Limits and audit);
  • a file the merge would write is open in an editor;
  • the host refuses the merged push.

The fetch is shallow, so the number of merged commits is a lower bound (“at least”).

Undo auto-merge

Undo auto-merge, in the notice, is for the owner and for editors with the Pro plan (as Take remote version). After a confirmation, it:

  • writes each merged file back to its content before the pull, as a new version tagged via: git auto-merge undo, and puts the import locks back;
  • resets the branch to Agrafe’s own checkpoint;
  • sets the status to Diverged. The remote branch keeps the merged commit, and nothing is merged again: pick one of the three choices below.

The rules:

  • Undo is available until the next checkpoint.
  • Edits made to the merged files since the merge are kept in their history; the confirmation lists those files.
  • Undo is refused with close <file> first while a merged file is open in an editor.
  • Undo deletes no version. A file the remote deleted had already been deleted by the merge, so it comes back as a new file with a single version; its old versions are still stored, but are not listed in the new file’s History.

The notice and its button are the same in the Git sync section and the History tab.

Choosing a resolution

When the status is Diverged, three buttons appear:

  • Take remote version asks for confirmation, then makes the project’s .dlf files and import locks those of the remote branch, as an import does: files are updated or created, and the .dlf, .md and Turtle files the branch lacks are deleted (package.dlf and Turtle sources are kept). Your local changes stay in the files’ version history. The status goes back to OK, and the next checkpoint builds on the remote branch.
  • Overwrite remote branch asks for confirmation, then force-pushes Agrafe’s last checkpoint over the remote branch. The commits made on that branch outside Agrafe are lost from it. Checkpoint first if there is no checkpoint yet.
  • Switch to new branch keeps the remote branch as it is and moves the sync to a new one: agrafe-2, then agrafe-3, skipping the names the remote already has. The next checkpoint pushes there.

Import locks

A project whose package.dlf imports other ontologies exports their locks with the files. The section warns in two cases:

  • an import line has no lock (it failed to resolve, or a release must be picked): the repository gets no .dolfin/imports/ files for it. Fix the line in the Imports field of the Package pane; the next checkpoint exports the lock.
  • lock files changed since the last checkpoint: they reach the repository with the next checkpoint.

Limits and audit

When Agrafe reads a repository (to import from it or take its version), it fetches only the branch’s last commit, and refuses or skips what is too big. To merge automatically, it fetches the history step by step, within the same size limits, until it finds its last pushed commit:

LimitValueOver it
Size of the files under the path prefix (the whole repository without a prefix, or when the host does not support partial fetches)50 MiBThe fetch stops and nothing is kept. A file over the per-file limit still counts here.
Entries under the path prefix1000Refused, nothing is kept.
Size of one file5 MiB, as for a data file in a projectThe file is skipped and listed.

Agrafe’s copy of the repository is compacted from time to time after pushes (git gc --auto).

Test connection, Pull now and Trust this host key are limited to 6 a minute per user, across projects; past that they fail with “too many requests, try again shortly”.

Text the remote sends (remote: lines) appears in errors prefixed “from the remote:”. It is the host’s text, not Agrafe’s: do not follow instructions in it you do not expect.

Connecting, switching or regenerating the SSH key (GitSyncUserKey, GitSyncKeyRegenerated), replacing a token, moving the token between Agrafe and the browser (GitSyncTokenMode, with mode=browser or mode=server), confirming a host key (GitSyncHostKeyConfirmed, with the fingerprint), disconnecting, overwriting the remote branch and importing are recorded in the server’s audit log, with the project, the user and the branch or commit. An automatic merge is recorded as GitSyncAutoMerge (branch, base, remote tip, merged commit, case) and its undo as GitSyncAutoMergeUndone (branch, base, merged commit); the merged versions are tagged via: git remote <sha>. The remote URL, the deploy key and the token are never recorded.

Who can do what

OwnerEditorViewer
See the status✓✓✓
Checkpoint, pause, resume✓✓
Connect, test, replace token, disconnect✓
Pull now, take remote version, undo auto-merge✓✓
Import from the repository✓
Overwrite remote branch, switch to new branch✓

The buttons you cannot use are hidden. Pulling, taking the remote version and undoing an auto-merge edit the project, so an editor needs the Pro plan that editing a shared project needs.