Skip to content

Git Data Layer

MicroResolve stores all training data — intents, phrases, learned weights — in a plain directory on disk. That directory is automatically initialized as a git repository. Every namespace mutation triggers a commit.

What this means for you

  • Full audit trail — every intent added, phrase removed, or correction applied is recorded as a commit with a timestamp.
  • Per-namespace rollback — you can restore any namespace to any historical state with a single API call.
  • Remote sync — point the server at a standard git remote (GitHub, GitLab, Gitea, etc.) and push training data for backup or multi-server replication.
  • Diff — see exactly which intents changed, which phrases were added or removed, between any two commits.

How it works

On startup, the server calls ensure_repo() on the data directory. If no .git/ exists, it runs git init silently. If no git identity is configured globally, it sets:

user.name = microresolve
user.email = microresolve@local

These are local settings scoped to the data repo — your global git config is not affected.

Every write operation (add intent, add phrase, correct, auto-learn) ends with an auto-commit that records which namespace file changed.

Data directory layout

~/.local/share/microresolve/
.git/
default/
intents.json
learned.json
support/
intents.json
learned.json
security/
intents.json
learned.json

Each namespace is a subdirectory. The intents.json file stores the seed phrases and metadata. The learned.json file stores the weights accumulated from corrections and auto-learn passes.

View history

Terminal window
curl "http://localhost:3001/api/namespaces/support/history"

Response:

{
"namespace_id": "support",
"commits": [
{
"sha": "abc1234def5678...",
"message": "add phrase to cancel_order",
"ts": 1745744100
},
{
"sha": "def5678abc1234...",
"message": "auto-learn: 3 phrases applied",
"ts": 1745740800
}
]
}

sha is the full 40-character commit hash. ts is a Unix timestamp (seconds).

Roll back a namespace

Terminal window
curl -X POST http://localhost:3001/api/namespaces/support/rollback \
-H "Content-Type: application/json" \
-d '{"sha": "def5678abc1234..."}'

The data directory is hard-reset to that commit and every loaded namespace is reloaded from disk.

Semantic diff

Terminal window
curl "http://localhost:3001/api/namespaces/support/diff"

Returns a structured diff of intents added, removed, or changed since the previous commit — more readable than a raw git diff.

Remote push

Configure a remote

Terminal window
curl -X PUT http://localhost:3001/api/settings/git \
-H "Content-Type: application/json" \
-d '{"remote_url": "git@github.com:your-org/microresolve-data.git"}'

Manual push

Terminal window
curl -X POST http://localhost:3001/api/git/push

Remote push is best-effort. If the push fails (network error, no remote configured), the server logs the failure but does not block the write operation.

Check remote config

Terminal window
curl http://localhost:3001/api/settings/git
# {"remote_url": "git@github.com:...", "auto_push": false, "has_repo": true}

Clear the remote

Terminal window
curl -X PUT http://localhost:3001/api/settings/git \
-H "Content-Type: application/json" \
-d '{"remote_url": null}'

Next