Skip to content

Add workspace-admin git backup service for private/common workspace trees#58

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-git-backup-feature
Draft

Add workspace-admin git backup service for private/common workspace trees#58
Copilot wants to merge 3 commits intomainfrom
copilot/add-git-backup-feature

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

This PR adds git-backed workspace persistence to workspace-admin: users can configure private and common repositories, have them materialized under $WORKSPACE_DIR, and keep them synchronized from inside/outside the container. It also splits the admin code so API, CLI, and git backup concerns are isolated.

  • Service decomposition (maintainability)

    • Split monolithic admin module into:
      • admin/main.py (CLI + process wiring)
      • admin/api.py (FastAPI routes)
      • admin/services.py (service template loading)
      • admin/git_backup.py (repo config/clone/sync logic)
  • Git backup feature in workspace-admin

    • Added TOML-style config loading for assets.private and assets.common.
    • Supports authenticated HTTPS remotes via GIT_REPO_USERNAME + GIT_REPO_TOKEN.
    • Initializes repositories and exposes them through configured GIT_DIR locations (private / common).
    • Runs periodic sync loop (default 5 min): fetch → pull (-X ours) → add/commit → push.
    • Logs clone/sync failures to logs/workspace-admin.log under workspace app directory.
  • CLI surface

    • Added flags:
      • --config (default $HOME/.workspace/config.env)
      • --git-sync-interval (default 300)
      • --disable-git-backup
    • Preserved existing service discovery behavior and path-prefix routing.
  • Configuration/docs updates

    • Added config.env.example and config.env templates for private/common repo mapping.
    • Updated admin README/docs to describe git backup configuration and new module layout.
  • Tests updated with modular structure

    • Replaced monolithic test_main.py with:
      • test_api.py
      • test_cli.py
      • test_git_backup.py
    • Added coverage for config parsing and workspace symlink exposure for both repositories.
HOME_DIR = "/home/dtaas-user"
WORKSPACE_DIR = "/workspace"
WORKSPACE_APP_DIR = ".workspace"

[assets.private]
GIT_REPO_URL = "https://gitlab.com/username/private-repository.git"
GIT_REPO_BRANCH = "main"
GIT_REPO_USERNAME = "gitlab-username"
GIT_REPO_TOKEN = "gitlab-api-token"
GIT_DIR = "private"
GIT_WORK_TREE = "assets/private"
Original prompt

This section details on the original issue you should resolve

<issue_title>[FEATURE] git backup of workspace files</issue_title>
<issue_description>### Describe the feature

As a user, I want to backup my workspace to git repos via workspace admin
so that I can access them both inside and outside the workspace

Describe the problems your feature request solves

The ~/workspace is currently mounted as a directory from host to the container. This means that the user can only access the workspace from inside the container. If the user wants to access the workspace from outside the container, they need to set up additional mechanisms, which can be cumbersome and slow. By allowing the user to backup their workspace to git repositories, they can access their workspace from anywhere and also have version control for their work. This also allows the user to easily share their workspace with others by giving them access to the git repository. Additionally, it provides a backup solution for the user's work in case of any issues with the container or host machine.

Describe the solution you'd like

The users should have access to the git repositories via the $WORKSPACE_DIR/private and $WORKSPACE_DIR/common directories, which are linked to the working tree directories specified in the config file. This allows the users to easily access their workspace from both inside and outside the container without needing to set up additional mechanisms. The workspace-admin application will handle the cloning of the git repositories and serving them to the users, making it a seamless experience for the users to access their workspace from anywhere.

The user places git config in $WORKSPACE_APP_DIR/config.env. The $WORKSPACE_APP_DIR/config.env.example file provides a template. The format of config file is

# Top-level paths
HOME_DIR = "/home/username"
WORKSPACE_DIR = "/workspace"
WORKSPACE_APP_DIR = ".workspace"

[assets]

# Git repository configuration
[assets.private]
GIT_REPO_URL = "https://gitlab.com/username/repository.git"
GIT_REPO_BRANCH = "main"
GIT_REPO_USERNAME = "gitlab-username"
# HTTP token for authentication
GIT_REPO_TOKEN = "gitlab-api-token"
# Relative to WORKSPACE_DIR
GIT_DIR = "private"
# Relative to WORKSPACE_APP_DIR
GIT_WORK_TREE = "assets/private"

[assets.common]
GIT_REPO_URL = "https://gitlab.com/username/repository.git"
GIT_REPO_BRANCH = "main"
GIT_REPO_USERNAME = "gitlab-username"
# HTTP token for authentication
GIT_REPO_TOKEN = "gitlab-api-token"
# Relative to WORKSPACE_DIR
GIT_DIR = "common"
# Relative to WORKSPACE_APP_DIR
GIT_WORK_TREE = "assets/common"

The workspace-admin clones the git repository specified in the config file and serves it to the user. The working tree directory of the git repositories is stored in the $WORKSPACE_APP_DIR/assets directory as specified in the config file. The users can then access the git directories from the $WORKSPACE_DIR/private and $WORKSPACE_DIR/common directories.

A short description of git directory and working tree definitions is as follows:

If you have a non-bare git repository, there are two parts to it: the git directory and the working tree:

The working tree has your checked out source code, with any changes you might have made.
The git directory is normally named .git, and is in the top level of your working tree - this contains all the history of your project, configuration settings, pointers to branches, the index (staging area) and so on.
While this is the default layout of a git repository, you can actually set any directories in the filesystem to be your git directory and working tree. You can change these directories from their defaults either with the --work-tree and --git-dir options to git or by using the GIT_DIR and GIT_WORK_TREE environment variables.

The workspace-admin will also handle the authentication to the git repositories using the provided credentials in the config file. The users can then use git commands to interact with the repositories, such as committing changes, pushing to remote, etc. In addition, the workspace-admin must

  1. Watch for changes in the repositories and update the working tree accordingly. Commit changes to files in the working tree with a time interval of 5 minutes.
  2. Handle any conflicts that may arise when pulling changes from the remote repository. If there are conflicts, the local version of the file should be kept.
  3. Handle any errors that may occur during the cloning, pulling, or pushing of the repositories and provide appropriate error messages to the users. These error messages are logged in the workspace-admin logs ($WORKSPACE_APP_DIR/logs/workspace-admin.log).

Additional context

This feature needs to be implemented in workspace/src/admin and the configuration file is located in workspace/src/admin/config.env. The workspace-admin w...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 16, 2026 12:18
Co-authored-by: prasadtalasila <9206466+prasadtalasila@users.noreply.github.com>
Co-authored-by: prasadtalasila <9206466+prasadtalasila@users.noreply.github.com>
Copilot AI changed the title [WIP] Add feature for git backup of workspace files Add workspace-admin git backup service for private/common workspace trees Feb 16, 2026
Copilot AI requested a review from prasadtalasila February 16, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[FEATURE] git backup of workspace files

2 participants