feat: add --readonly flag for worker sandboxes (gt-ymo)
Add a --readonly flag that blocks all write operations, allowing workers to read beads state without modifying it. Workers can use: - bd show, bd list, bd ready (read operations) Workers cannot use: - bd create, bd update, bd close, bd sync, etc. (write operations) The flag can be set via: - --readonly flag on command line - BD_READONLY=true environment variable - readonly: true in config file This enables swarm workers to see their assigned work from a static snapshot of the beads database without accidentally modifying it. Commands protected by readonly mode: - create, update, close, delete, edit - sync, import, reopen - comment add, dep add/remove, label add/remove - repair-deps, compact, migrate, migrate-hash-ids, migrate-issues - rename-prefix, validate --fix-all, duplicates --auto-merge - epic close-eligible, jira sync 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -101,6 +101,7 @@ var (
|
||||
sandboxMode bool
|
||||
allowStale bool // Use --allow-stale: skip staleness check (emergency escape hatch)
|
||||
noDb bool // Use --no-db mode: load from JSONL, write back after each command
|
||||
readonlyMode bool // Read-only mode: block write operations (for worker sandboxes)
|
||||
profileEnabled bool
|
||||
profileFile *os.File
|
||||
traceFile *os.File
|
||||
@@ -124,6 +125,7 @@ func init() {
|
||||
rootCmd.PersistentFlags().BoolVar(&sandboxMode, "sandbox", false, "Sandbox mode: disables daemon and auto-sync")
|
||||
rootCmd.PersistentFlags().BoolVar(&allowStale, "allow-stale", false, "Allow operations on potentially stale data (skip staleness check)")
|
||||
rootCmd.PersistentFlags().BoolVar(&noDb, "no-db", false, "Use no-db mode: load from JSONL, no SQLite")
|
||||
rootCmd.PersistentFlags().BoolVar(&readonlyMode, "readonly", false, "Read-only mode: block write operations (for worker sandboxes)")
|
||||
rootCmd.PersistentFlags().BoolVar(&profileEnabled, "profile", false, "Generate CPU profile for performance analysis")
|
||||
rootCmd.PersistentFlags().BoolVarP(&verboseFlag, "verbose", "v", false, "Enable verbose/debug output")
|
||||
rootCmd.PersistentFlags().BoolVarP(&quietFlag, "quiet", "q", false, "Suppress non-essential output (errors only)")
|
||||
@@ -173,6 +175,9 @@ var rootCmd = &cobra.Command{
|
||||
if !cmd.Flags().Changed("no-db") {
|
||||
noDb = config.GetBool("no-db")
|
||||
}
|
||||
if !cmd.Flags().Changed("readonly") {
|
||||
readonlyMode = config.GetBool("readonly")
|
||||
}
|
||||
if !cmd.Flags().Changed("db") && dbPath == "" {
|
||||
dbPath = config.GetString("db")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user