You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DMC primary checkouts currently serve three roles at once: default-branch reference, mutable working tree, and base for creating task worktrees. That makes stale reads and accidental default-branch mutations likely.
6
+
7
+
## Target Model
8
+
9
+
- A primary mirror is DMC-owned reference state for a remote default branch.
10
+
- Agents do feature, release, and repair work only in managed `repo@slug` worktrees.
11
+
- Mirror refresh is a narrow operation: fetch and fast-forward to the tracked remote ref.
12
+
- Dangerous operations on mirrors are blocked by default and require explicit operator approval.
13
+
- Read surfaces fail closed when a mirror is stale, diverged, detached, or otherwise unsafe unless the caller opts in with stale-read metadata.
14
+
15
+
## Migration Plan
16
+
17
+
1. Keep existing primary directories as the compatibility mirror path.
18
+
2. Enforce tactical safety first: separate primary refresh from dangerous primary mutation, and guard stale primary reads.
19
+
3. Add mirror metadata to each primary row: remote URL, tracked ref, last refresh result, freshness state, and whether local commits/dirty state block automated conversion.
20
+
4. For clean/current primaries, mark them `mirror_compatible` and allow DMC to refresh them as mirrors.
21
+
5. For dirty/diverged primaries, keep them read-protected and report a non-destructive remediation plan: preserve local commits in a worktree, push/open PR if needed, or archive before mirror conversion.
22
+
6. After migration, create release/default-branch work via explicit managed worktrees, not the mirror.
23
+
24
+
## Command Shape
25
+
26
+
- Investigation: `workspace show <repo>` then `workspace read <repo>@<slug> ...` or `workspace read <repo> ... --allow-stale-primary` when intentionally inspecting stale local state.
* : Relative path (repeatable) for add/diff operations. Named `--rel`
2602
2623
* to avoid colliding with WP-CLI's documented global `--path` flag.
2603
2624
*
2604
-
* [--allow-dirty]
2605
-
* : Allow pull with dirty working tree.
2606
-
*
2607
-
* [--allow-primary-mutation]
2608
-
* : Permit mutating ops (pull/add/commit/push) on the primary checkout. Default-deny — use a worktree handle (`<repo>@<branch-slug>`) instead whenever possible.
2625
+
* [--allow-dirty]
2626
+
* : Allow pull with dirty working tree.
2627
+
*
2628
+
* [--allow-primary-refresh]
2629
+
* : Permit safe primary refresh with `git pull --ff-only`.
2630
+
*
2631
+
* [--allow-primary-mutation]
2632
+
* : Legacy alias for `--allow-primary-refresh` on `git pull`, and for non-dangerous primary file/index mutations. Does not permit primary commit, push, reset, or rebase.
2633
+
*
2634
+
* [--allow-dangerous-primary-mutation]
2635
+
* : Permit primary commit, push, reset, or rebase. Use only for an explicitly approved primary mutation.
2609
2636
*
2610
2637
* [--remote=<remote>]
2611
2638
* : Remote name for pull/push (default: origin).
@@ -2687,8 +2714,11 @@ public function git( array $args, array $assoc_args ): void {
2687
2714
2688
2715
$input = array( 'name' => $repo );
2689
2716
2690
-
// Mutating ops accept --allow-primary-mutation to operate on a primary checkout.
- **GitHub:** `{$wp} datamachine-code github {$github_subcmds}` — list/read GitHub state, manage issues and PRs, install review flows, and comment on reviews.
145
145
- **Editing inside a worktree:** any tool. Local agents on the same disk should use native file I/O and raw `git`; routing edits through workspace abilities is ceremony, not safety.
146
146
- **Workspace lifecycle:** use `workspace clone` for primary checkout adoption/cloning and `workspace worktree add` for isolated branches. Use the CLI `--help` output for current flags and subcommands.
147
-
- **Primary freshness:** before using a primary checkout for investigation or verification, inspect `workspace list|show|hygiene` freshness metadata. If the primary is stale, run `workspace git pull <repo> --allow-primary-mutation` or create the worktree from an explicit remote ref with `worktree add <repo> <branch> --from=origin/<base>`. Do not clone a second top-level primary for the same remote just to get fresh code.
148
-
- **Primary is read-only.** Never edit `<workspace>/<repo>` (no `@slug`). Mutating ops on bare `<repo>` handles via the CLI require `--allow-primary-mutation`. The primary tracks the deployed branch — operate on a worktree.
147
+
- **Primary freshness:** before using a primary checkout for investigation or verification, inspect `workspace list|show|hygiene` freshness metadata. If the primary is stale, run `workspace git pull <repo> --allow-primary-refresh` or create the worktree from an explicit remote ref with `worktree add <repo> <branch> --from=origin/<base>`. Stale primary reads require an explicit `--allow-stale-primary` opt-in. Do not clone a second top-level primary for the same remote just to get fresh code.
148
+
- **Primary is read-only.** Never edit `<workspace>/<repo>` (no `@slug`). Safe primary refresh uses `--allow-primary-refresh`; primary commit, push, reset, and rebase require the stronger `--allow-dangerous-primary-mutation` approval. The primary tracks the deployed branch — operate on a worktree.
149
149
- **Rule:** Never modify files under `wp-content/plugins/` or `wp-content/themes/` directly. Those paths are **read-only reference**. All code changes go through the workspace so they are tracked in git and reviewed via pull requests.
150
150
151
151
**System:** `{$wp} datamachine system health|prompts|run` — site health, prompt inspection, diagnostic runs.
0 commit comments