Skip to content
Source
Sign inSign up

Protect files with read-only paths

Work with agents / Local workspaces

Protect files with read-only paths

Some files must not change in agent work, for example a database schema or the CI config. Name them as read-only paths, and src ws accept refuses a workspace that changes them.

1 min read

1. Name the paths

In .source/workspace.yaml, name the read-only files in the paths section:

paths:
  readOnly: ["schema/**", ".source/**"]

Or name the files that agents can change. Then every other path is read-only:

paths:
  readWrite: ["src/**", "test/**"]

* stays in one folder, and ** crosses folders. So docs/** matches every file under docs.

2. Create the workspaces

src ws create api

src ws create sets the read-only flag of the OS on those files in the workspace.

Warning

The flag guards against mistakes only. A process in the workspace can clear it.

Done

src ws accept refuses a workspace that changes a read-only path. It names each file, and applies nothing.

src reads the rules from your checkout, never from a workspace.

Add rules for one workspace

To add rules for one workspace only, use --read-only. It adds to the rules of the repository, and a child workspace keeps the rules of its parent:

src ws create api --read-only "docs/**"