gitgrip 1.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. gitgrip-1.5.0.dist-info/METADATA +13 -0
  2. gitgrip-1.5.0.dist-info/RECORD +80 -0
  3. gitgrip-1.5.0.dist-info/WHEEL +5 -0
  4. gitgrip-1.5.0.dist-info/entry_points.txt +2 -0
  5. gitgrip-1.5.0.dist-info/top_level.txt +2 -0
  6. gr2/__init__.py +0 -0
  7. gr2/overlay/__init__.py +6 -0
  8. gr2/overlay/activate.py +196 -0
  9. gr2/overlay/agent_manifest.py +138 -0
  10. gr2/overlay/cli.py +181 -0
  11. gr2/overlay/cross_repo.py +124 -0
  12. gr2/overlay/drivers.py +113 -0
  13. gr2/overlay/introspection.py +155 -0
  14. gr2/overlay/language_drivers.py +115 -0
  15. gr2/overlay/objects.py +412 -0
  16. gr2/overlay/perf.py +251 -0
  17. gr2/overlay/refs.py +36 -0
  18. gr2/overlay/trust.py +150 -0
  19. gr2/overlay/types.py +69 -0
  20. gr2/overlay/units.py +313 -0
  21. gr2/overlay/workspace_spec.py +59 -0
  22. gr2/prototypes/__init__.py +0 -0
  23. gr2/prototypes/cache_materialization_probe.py +190 -0
  24. gr2/prototypes/concurrent_event_stress.py +199 -0
  25. gr2/prototypes/concurrent_lease_stress.py +240 -0
  26. gr2/prototypes/concurrent_workspace_cap_stress.py +231 -0
  27. gr2/prototypes/contribution_protocol.py +665 -0
  28. gr2/prototypes/cross_mode_lane_stress.py +986 -0
  29. gr2/prototypes/jsonl_store.py +158 -0
  30. gr2/prototypes/lane_workspace_prototype.py +2088 -0
  31. gr2/prototypes/layout_model_probe.py +139 -0
  32. gr2/prototypes/propagation_daemon.py +546 -0
  33. gr2/prototypes/propagation_state_machine.py +1478 -0
  34. gr2/prototypes/python_exec_playground.py +194 -0
  35. gr2/prototypes/python_hook_runtime_playground.py +240 -0
  36. gr2/prototypes/python_migration_playground.py +144 -0
  37. gr2/prototypes/python_review_checkout_playground.py +242 -0
  38. gr2/prototypes/python_spec_apply_playground.py +282 -0
  39. gr2/prototypes/real_git_lane_materialization.py +248 -0
  40. gr2/prototypes/real_git_playground.py +334 -0
  41. gr2/prototypes/recall_lane_history.py +274 -0
  42. gr2/prototypes/repo_maintenance_prototype.py +659 -0
  43. gr2/prototypes/repo_transport_probe.py +147 -0
  44. gr2/python_cli/__init__.py +2 -0
  45. gr2/python_cli/__main__.py +6 -0
  46. gr2/python_cli/add.py +51 -0
  47. gr2/python_cli/app.py +2516 -0
  48. gr2/python_cli/branch.py +67 -0
  49. gr2/python_cli/channel_bridge.py +131 -0
  50. gr2/python_cli/clone_exec.py +1019 -0
  51. gr2/python_cli/commit.py +199 -0
  52. gr2/python_cli/config.py +291 -0
  53. gr2/python_cli/env_exec.py +419 -0
  54. gr2/python_cli/events.py +529 -0
  55. gr2/python_cli/execops.py +372 -0
  56. gr2/python_cli/failures.py +98 -0
  57. gr2/python_cli/file_exec.py +256 -0
  58. gr2/python_cli/gitops.py +226 -0
  59. gr2/python_cli/grip.py +1337 -0
  60. gr2/python_cli/grip_cli.py +493 -0
  61. gr2/python_cli/hooks.py +450 -0
  62. gr2/python_cli/launch_exec.py +786 -0
  63. gr2/python_cli/merge_verification.py +274 -0
  64. gr2/python_cli/migration.py +985 -0
  65. gr2/python_cli/open_gr_review.py +699 -0
  66. gr2/python_cli/platform.py +441 -0
  67. gr2/python_cli/pr.py +487 -0
  68. gr2/python_cli/project_review.py +314 -0
  69. gr2/python_cli/prune.py +365 -0
  70. gr2/python_cli/push.py +172 -0
  71. gr2/python_cli/review.py +462 -0
  72. gr2/python_cli/review_ephemeral.py +143 -0
  73. gr2/python_cli/review_run.py +621 -0
  74. gr2/python_cli/spec_apply.py +1285 -0
  75. gr2/python_cli/staging_cleanup.py +205 -0
  76. gr2/python_cli/syncops.py +920 -0
  77. gr2/python_cli/target.py +100 -0
  78. gr2/python_cli/workspace_snapshot.py +105 -0
  79. gr2/schemas/gr2-materialization-plan-v1.schema.json +191 -0
  80. gr2_overlay/__init__.py +37 -0
@@ -0,0 +1,248 @@
1
+ #!/usr/bin/env python3
2
+ """Prototype real-git same-repo multi-agent lane materialization."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import json
8
+ import shutil
9
+ import subprocess
10
+ import tempfile
11
+ from pathlib import Path
12
+
13
+
14
+ def parse_args() -> argparse.Namespace:
15
+ parser = argparse.ArgumentParser(
16
+ description="Verify real-git same-repo lane materialization"
17
+ )
18
+ parser.add_argument(
19
+ "--workspace-root",
20
+ type=Path,
21
+ help="optional workspace root; defaults to a temporary workspace",
22
+ )
23
+ parser.add_argument("--json", action="store_true")
24
+ return parser.parse_args()
25
+
26
+
27
+ def repo_root() -> Path:
28
+ return Path(__file__).resolve().parents[2]
29
+
30
+
31
+ def lane_proto(root: Path) -> Path:
32
+ return root / "gr2" / "prototypes" / "lane_workspace_prototype.py"
33
+
34
+
35
+ def run(
36
+ argv: list[str],
37
+ *,
38
+ cwd: Path | None = None,
39
+ capture: bool = False,
40
+ check: bool = True,
41
+ ) -> subprocess.CompletedProcess[str]:
42
+ return subprocess.run(
43
+ argv,
44
+ cwd=cwd,
45
+ check=check,
46
+ text=True,
47
+ capture_output=capture,
48
+ )
49
+
50
+
51
+ def init_workspace(workspace_root: Path, bare_remote: Path) -> None:
52
+ (workspace_root / ".grip").mkdir(parents=True, exist_ok=True)
53
+ (workspace_root / "agents").mkdir(exist_ok=True)
54
+ spec = f"""schema_version = 1
55
+ workspace_name = "real-git-lane-materialization"
56
+
57
+ [cache]
58
+ root = ".grip/cache"
59
+
60
+ [[repos]]
61
+ name = "app"
62
+ path = "repos/app"
63
+ url = "{bare_remote}"
64
+
65
+ [[units]]
66
+ name = "atlas"
67
+ path = "agents/atlas"
68
+ agent_id = "atlas-agent"
69
+ repos = ["app"]
70
+
71
+ [[units]]
72
+ name = "apollo"
73
+ path = "agents/apollo"
74
+ agent_id = "apollo-agent"
75
+ repos = ["app"]
76
+ """
77
+ (workspace_root / ".grip" / "workspace_spec.toml").write_text(spec)
78
+
79
+
80
+ def seed_bare_remote(root: Path) -> Path:
81
+ remotes = root / "remotes"
82
+ work = root / "seed-work"
83
+ remotes.mkdir(parents=True, exist_ok=True)
84
+ run(["git", "init", "--bare", str(remotes / "app.git")])
85
+ run(["git", "init", str(work)])
86
+ run(["git", "config", "user.name", "Playground User"], cwd=work)
87
+ run(["git", "config", "user.email", "playground@example.com"], cwd=work)
88
+ (work / "README.md").write_text("# app\n")
89
+ run(["git", "add", "README.md"], cwd=work)
90
+ run(["git", "commit", "-m", "Initial commit"], cwd=work)
91
+ run(["git", "branch", "-M", "main"], cwd=work)
92
+ run(["git", "remote", "add", "origin", str(remotes / "app.git")], cwd=work)
93
+ run(["git", "push", "-u", "origin", "main"], cwd=work)
94
+ return remotes / "app.git"
95
+
96
+
97
+ def create_lane(
98
+ root: Path, workspace_root: Path, owner_unit: str, lane_name: str, branch: str
99
+ ) -> None:
100
+ run(
101
+ [
102
+ "python3",
103
+ str(lane_proto(root)),
104
+ "create-lane",
105
+ str(workspace_root),
106
+ owner_unit,
107
+ lane_name,
108
+ "--repos",
109
+ "app",
110
+ "--branch",
111
+ branch,
112
+ ]
113
+ )
114
+
115
+
116
+ def plan_exec_json(
117
+ root: Path, workspace_root: Path, owner_unit: str, lane_name: str
118
+ ) -> list[dict]:
119
+ proc = run(
120
+ [
121
+ "python3",
122
+ str(lane_proto(root)),
123
+ "plan-exec",
124
+ str(workspace_root),
125
+ owner_unit,
126
+ lane_name,
127
+ "git status",
128
+ "--json",
129
+ ],
130
+ capture=True,
131
+ )
132
+ return json.loads(proc.stdout)
133
+
134
+
135
+ def configure_checkout(repo_path: Path, user_name: str, user_email: str) -> None:
136
+ run(["git", "config", "user.name", user_name], cwd=repo_path)
137
+ run(["git", "config", "user.email", user_email], cwd=repo_path)
138
+
139
+
140
+ def clone_into_lane(
141
+ remote: Path, cwd_path: Path, branch: str, user_name: str, user_email: str
142
+ ) -> None:
143
+ cwd_path.parent.mkdir(parents=True, exist_ok=True)
144
+ run(["git", "clone", str(remote), str(cwd_path)])
145
+ configure_checkout(cwd_path, user_name, user_email)
146
+ run(["git", "checkout", "-b", branch], cwd=cwd_path)
147
+
148
+
149
+ def commit_lane_change(
150
+ repo_path: Path, filename: str, contents: str, message: str
151
+ ) -> str:
152
+ (repo_path / filename).write_text(contents)
153
+ run(["git", "add", filename], cwd=repo_path)
154
+ run(["git", "commit", "-m", message], cwd=repo_path)
155
+ proc = run(["git", "rev-parse", "HEAD"], cwd=repo_path, capture=True)
156
+ return proc.stdout.strip()
157
+
158
+
159
+ def verify(workspace_root: Path) -> dict:
160
+ root = repo_root()
161
+ remote = seed_bare_remote(workspace_root / ".tmp")
162
+ init_workspace(workspace_root, remote)
163
+
164
+ create_lane(root, workspace_root, "atlas", "feat-router", "feat/router")
165
+ create_lane(root, workspace_root, "apollo", "feat-materialize", "feat/materialize")
166
+
167
+ atlas_plan = plan_exec_json(root, workspace_root, "atlas", "feat-router")
168
+ apollo_plan = plan_exec_json(root, workspace_root, "apollo", "feat-materialize")
169
+
170
+ atlas_cwd = Path(atlas_plan[0]["cwd"])
171
+ apollo_cwd = Path(apollo_plan[0]["cwd"])
172
+
173
+ clone_into_lane(remote, atlas_cwd, "feat/router", "Atlas User", "atlas@example.com")
174
+ clone_into_lane(
175
+ remote,
176
+ apollo_cwd,
177
+ "feat/materialize",
178
+ "Apollo User",
179
+ "apollo@example.com",
180
+ )
181
+
182
+ atlas_commit = commit_lane_change(
183
+ atlas_cwd, "atlas.txt", "atlas lane change\n", "atlas lane commit"
184
+ )
185
+ apollo_commit = commit_lane_change(
186
+ apollo_cwd, "apollo.txt", "apollo lane change\n", "apollo lane commit"
187
+ )
188
+
189
+ atlas_status = run(["git", "status", "--short"], cwd=atlas_cwd, capture=True).stdout.strip()
190
+ apollo_status = run(["git", "status", "--short"], cwd=apollo_cwd, capture=True).stdout.strip()
191
+
192
+ result = {
193
+ "atlas_cwd": str(atlas_cwd),
194
+ "apollo_cwd": str(apollo_cwd),
195
+ "cwd_collision": atlas_cwd == apollo_cwd,
196
+ "atlas_commit": atlas_commit,
197
+ "apollo_commit": apollo_commit,
198
+ "commit_collision": atlas_commit == apollo_commit,
199
+ "atlas_has_apollo_file": (atlas_cwd / "apollo.txt").exists(),
200
+ "apollo_has_atlas_file": (apollo_cwd / "atlas.txt").exists(),
201
+ "atlas_clean": atlas_status == "",
202
+ "apollo_clean": apollo_status == "",
203
+ }
204
+ result["verdict"] = (
205
+ "holds"
206
+ if not result["cwd_collision"]
207
+ and not result["commit_collision"]
208
+ and not result["atlas_has_apollo_file"]
209
+ and not result["apollo_has_atlas_file"]
210
+ and result["atlas_clean"]
211
+ and result["apollo_clean"]
212
+ else "fails"
213
+ )
214
+ return result
215
+
216
+
217
+ def main() -> int:
218
+ args = parse_args()
219
+ if args.workspace_root:
220
+ workspace_root = args.workspace_root.resolve()
221
+ if workspace_root.exists():
222
+ shutil.rmtree(workspace_root)
223
+ workspace_root.mkdir(parents=True, exist_ok=True)
224
+ result = verify(workspace_root)
225
+ else:
226
+ with tempfile.TemporaryDirectory(prefix="gr2-real-git-lanes-") as tmp:
227
+ workspace_root = Path(tmp)
228
+ result = verify(workspace_root)
229
+
230
+ if args.json:
231
+ print(json.dumps(result, indent=2))
232
+ else:
233
+ print("gr2 real-git same-repo lane materialization")
234
+ print(f'workspace: {workspace_root}')
235
+ print(f'verdict: {result["verdict"]}')
236
+ print(f'atlas cwd: {result["atlas_cwd"]}')
237
+ print(f'apollo cwd: {result["apollo_cwd"]}')
238
+ print(f'cwd collision: {result["cwd_collision"]}')
239
+ print(f'commit collision: {result["commit_collision"]}')
240
+ print(f'atlas sees apollo file: {result["atlas_has_apollo_file"]}')
241
+ print(f'apollo sees atlas file: {result["apollo_has_atlas_file"]}')
242
+ print(f'atlas clean: {result["atlas_clean"]}')
243
+ print(f'apollo clean: {result["apollo_clean"]}')
244
+ return 0
245
+
246
+
247
+ if __name__ == "__main__":
248
+ raise SystemExit(main())
@@ -0,0 +1,334 @@
1
+ #!/usr/bin/env python3
2
+ """Validate the Python-first gr2 surface against real GitHub remotes.
3
+
4
+ This harness does not try to prove every future workflow. It validates the
5
+ current product-critical path against the real synapt-dev playground repos:
6
+
7
+ - bootstrap from a real workspace spec
8
+ - feature-lane coexistence across multiple repos
9
+ - review-lane isolation from feature work
10
+ - exec status honesty against actual checkout state
11
+ - dirty-state detection and recovery
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import argparse
17
+ import json
18
+ import os
19
+ import shutil
20
+ import subprocess
21
+ import sys
22
+ from pathlib import Path
23
+
24
+
25
+ ROOT = Path(__file__).resolve().parents[2]
26
+ PLAYGROUND_REPOS = {
27
+ "app": {
28
+ "ssh": "git@github.com:synapt-dev/gr2-playground-app.git",
29
+ "https": "https://github.com/synapt-dev/gr2-playground-app.git",
30
+ },
31
+ "api": {
32
+ "ssh": "git@github.com:synapt-dev/gr2-playground-api.git",
33
+ "https": "https://github.com/synapt-dev/gr2-playground-api.git",
34
+ },
35
+ "web": {
36
+ "ssh": "git@github.com:synapt-dev/gr2-playground-web.git",
37
+ "https": "https://github.com/synapt-dev/gr2-playground-web.git",
38
+ },
39
+ }
40
+
41
+
42
+ def parse_args() -> argparse.Namespace:
43
+ parser = argparse.ArgumentParser(description="Validate gr2 against real synapt-dev playground repos.")
44
+ parser.add_argument("workspace_root", type=Path)
45
+ parser.add_argument("--owner-unit", default="atlas")
46
+ parser.add_argument("--workspace-name", default="gr2-real-git-playground")
47
+ parser.add_argument("--transport", choices=["ssh", "https"], default="https")
48
+ parser.add_argument("--keep-existing", action="store_true")
49
+ parser.add_argument("--json", action="store_true")
50
+ return parser.parse_args()
51
+
52
+
53
+ def run(args: list[str], *, cwd: Path | None = None, check: bool = True) -> subprocess.CompletedProcess[str]:
54
+ env = os.environ.copy()
55
+ env["PYTHONPATH"] = str(ROOT)
56
+ proc = subprocess.run(args, cwd=cwd, env=env, text=True, capture_output=True)
57
+ if check and proc.returncode != 0:
58
+ raise SystemExit(f"command failed: {args}\nstdout={proc.stdout}\nstderr={proc.stderr}")
59
+ return proc
60
+
61
+
62
+ def pygr2(*args: str, cwd: Path | None = None, check: bool = True) -> subprocess.CompletedProcess[str]:
63
+ return run(["python3", "-m", "gr2.python_cli", *args], cwd=cwd, check=check)
64
+
65
+
66
+ def git(*args: str, cwd: Path | None = None, check: bool = True) -> subprocess.CompletedProcess[str]:
67
+ return run(["git", *args], cwd=cwd, check=check)
68
+
69
+
70
+ def repo_url(repo_name: str, transport: str) -> str:
71
+ return PLAYGROUND_REPOS[repo_name][transport]
72
+
73
+
74
+ def write_workspace_spec(workspace_root: Path, owner_unit: str, workspace_name: str, transport: str) -> None:
75
+ grip_dir = workspace_root / ".grip"
76
+ grip_dir.mkdir(parents=True, exist_ok=True)
77
+ (grip_dir / "workspace_spec.toml").write_text(
78
+ "\n".join(
79
+ [
80
+ "schema_version = 1",
81
+ f'workspace_name = "{workspace_name}"',
82
+ "",
83
+ "[[repos]]",
84
+ 'name = "app"',
85
+ 'path = "repos/app"',
86
+ f'url = "{repo_url("app", transport)}"',
87
+ "",
88
+ "[[repos]]",
89
+ 'name = "api"',
90
+ 'path = "repos/api"',
91
+ f'url = "{repo_url("api", transport)}"',
92
+ "",
93
+ "[[repos]]",
94
+ 'name = "web"',
95
+ 'path = "repos/web"',
96
+ f'url = "{repo_url("web", transport)}"',
97
+ "",
98
+ "[[units]]",
99
+ f'name = "{owner_unit}"',
100
+ f'path = "agents/{owner_unit}/home"',
101
+ 'repos = ["app", "api", "web"]',
102
+ "",
103
+ ]
104
+ )
105
+ )
106
+
107
+
108
+ def ensure_workspace_root(path: Path, *, keep_existing: bool) -> None:
109
+ if path.exists():
110
+ if keep_existing:
111
+ return
112
+ if any(path.iterdir()):
113
+ shutil.rmtree(path)
114
+ else:
115
+ path.rmdir()
116
+ path.mkdir(parents=True, exist_ok=True)
117
+
118
+
119
+ def lane_repo_root(workspace_root: Path, owner_unit: str, lane_name: str, repo_name: str) -> Path:
120
+ return workspace_root / "agents" / owner_unit / "lanes" / lane_name / "repos" / repo_name
121
+
122
+
123
+ def read_json(proc: subprocess.CompletedProcess[str]) -> object:
124
+ return json.loads(proc.stdout)
125
+
126
+
127
+ def branch_name(repo_root: Path) -> str:
128
+ return git("branch", "--show-current", cwd=repo_root).stdout.strip()
129
+
130
+
131
+ def remote_origin(repo_root: Path) -> str:
132
+ return git("config", "--get", "remote.origin.url", cwd=repo_root).stdout.strip()
133
+
134
+
135
+ def stash_entries(repo_root: Path) -> list[str]:
136
+ return [line for line in git("stash", "list", cwd=repo_root).stdout.splitlines() if line.strip()]
137
+
138
+
139
+ def repo_status_row(rows: list[dict[str, object]], *, scope: str, repo: str) -> dict[str, object]:
140
+ for row in rows:
141
+ if row["scope"] == scope and row["repo"] == repo:
142
+ return row
143
+ raise SystemExit(f"repo status row not found for scope={scope} repo={repo}")
144
+
145
+
146
+ def scenario_real_remote_bootstrap(workspace_root: Path, owner_unit: str, transport: str) -> dict[str, object]:
147
+ payload = read_json(pygr2("apply", str(workspace_root), "--yes", "--json"))
148
+ shared_roots = {name: workspace_root / "repos" / name for name in PLAYGROUND_REPOS}
149
+ cache_roots = {
150
+ name: workspace_root / ".grip" / "cache" / "repos" / f"{name}.git"
151
+ for name in PLAYGROUND_REPOS
152
+ }
153
+ holds = "workspace_root" in payload and "operation_count" in payload
154
+ for repo_name, repo_root in shared_roots.items():
155
+ holds = holds and repo_root.joinpath(".git").exists()
156
+ holds = holds and remote_origin(repo_root) == repo_url(repo_name, transport)
157
+ holds = holds and cache_roots[repo_name].exists()
158
+ return {
159
+ "name": "real-remote-bootstrap",
160
+ "holds": holds,
161
+ "payload": payload,
162
+ }
163
+
164
+
165
+ def scenario_multi_lane_coexistence(workspace_root: Path, owner_unit: str) -> dict[str, object]:
166
+ pygr2(
167
+ "lane",
168
+ "create",
169
+ str(workspace_root),
170
+ owner_unit,
171
+ "feat-auth",
172
+ "--repos",
173
+ "app,api",
174
+ "--branch",
175
+ "feat/auth",
176
+ )
177
+ pygr2("lane", "enter", str(workspace_root), owner_unit, "feat-auth", "--actor", "agent:atlas")
178
+ pygr2(
179
+ "lane",
180
+ "create",
181
+ str(workspace_root),
182
+ owner_unit,
183
+ "feat-web",
184
+ "--repos",
185
+ "web",
186
+ "--branch",
187
+ "feat/web",
188
+ )
189
+ pygr2("lane", "enter", str(workspace_root), owner_unit, "feat-web", "--actor", "agent:atlas")
190
+ current = read_json(pygr2("lane", "current", str(workspace_root), owner_unit, "--json"))
191
+ feat_auth_app = lane_repo_root(workspace_root, owner_unit, "feat-auth", "app")
192
+ feat_auth_api = lane_repo_root(workspace_root, owner_unit, "feat-auth", "api")
193
+ feat_web = lane_repo_root(workspace_root, owner_unit, "feat-web", "web")
194
+ return {
195
+ "name": "multi-lane-coexistence",
196
+ "holds": current["current"]["lane_name"] == "feat-web"
197
+ and feat_auth_app.exists()
198
+ and feat_auth_api.exists()
199
+ and feat_web.exists()
200
+ and branch_name(feat_auth_app) == "feat/auth"
201
+ and branch_name(feat_auth_api) == "feat/auth"
202
+ and branch_name(feat_web) == "feat/web",
203
+ "payload": {
204
+ "current": current,
205
+ "feat_auth_app": str(feat_auth_app),
206
+ "feat_auth_api": str(feat_auth_api),
207
+ "feat_web": str(feat_web),
208
+ },
209
+ }
210
+
211
+
212
+ def scenario_review_lane_isolation(workspace_root: Path, owner_unit: str) -> dict[str, object]:
213
+ shared_app = workspace_root / "repos" / "app"
214
+ git("checkout", "-B", "validation/base", cwd=shared_app)
215
+ payload = read_json(
216
+ pygr2(
217
+ "review",
218
+ "checkout-pr",
219
+ str(workspace_root),
220
+ owner_unit,
221
+ "app",
222
+ "101",
223
+ "--branch",
224
+ "main",
225
+ "--lane",
226
+ "review-app-101",
227
+ "--enter",
228
+ "--actor",
229
+ "agent:atlas",
230
+ "--json",
231
+ )
232
+ )
233
+ current = read_json(pygr2("lane", "current", str(workspace_root), owner_unit, "--json"))
234
+ feat_auth_app = lane_repo_root(workspace_root, owner_unit, "feat-auth", "app")
235
+ review_app = lane_repo_root(workspace_root, owner_unit, "review-app-101", "app")
236
+ return {
237
+ "name": "review-lane-isolation",
238
+ "holds": payload["lane_name"] == "review-app-101"
239
+ and current["current"]["lane_name"] == "review-app-101"
240
+ and branch_name(feat_auth_app) == "feat/auth"
241
+ and branch_name(review_app) == "main"
242
+ and feat_auth_app != review_app,
243
+ "payload": payload,
244
+ }
245
+
246
+
247
+ def scenario_exec_status_honest(workspace_root: Path, owner_unit: str) -> dict[str, object]:
248
+ pygr2("lane", "enter", str(workspace_root), owner_unit, "feat-auth", "--actor", "agent:atlas")
249
+ payload = read_json(pygr2("exec", "status", str(workspace_root), owner_unit, "--json"))
250
+ rows = {row["repo"]: row for row in payload["rows"]}
251
+ app_root = lane_repo_root(workspace_root, owner_unit, "feat-auth", "app")
252
+ api_root = lane_repo_root(workspace_root, owner_unit, "feat-auth", "api")
253
+ holds = payload["status"] == "ready" and payload["lane"] == "feat-auth"
254
+ holds = holds and rows["app"]["cwd"] == str(app_root) and rows["api"]["cwd"] == str(api_root)
255
+ holds = holds and rows["app"]["exists"] is True and rows["api"]["exists"] is True
256
+ holds = holds and rows["app"]["branch"] == "feat/auth" and rows["api"]["branch"] == "feat/auth"
257
+ holds = holds and branch_name(app_root) == "feat/auth" and branch_name(api_root) == "feat/auth"
258
+ return {
259
+ "name": "exec-status-honest",
260
+ "holds": holds,
261
+ "payload": payload,
262
+ }
263
+
264
+
265
+ def scenario_dirty_state_and_recovery(workspace_root: Path, owner_unit: str) -> dict[str, object]:
266
+ shared_app = workspace_root / "repos" / "app"
267
+ shared_readme = shared_app / "README.md"
268
+ shared_readme.write_text(shared_readme.read_text() + "\nreal-git dirty check\n")
269
+ repo_status = read_json(pygr2("repo", "status", str(workspace_root), "--json"))
270
+ app_status = repo_status_row(repo_status, scope="shared", repo="app")
271
+ sync_block = read_json(pygr2("sync", "status", str(workspace_root), "--dirty", "block", "--json"))
272
+
273
+ pygr2("lane", "enter", str(workspace_root), owner_unit, "feat-web", "--actor", "agent:atlas")
274
+ feat_web_repo = lane_repo_root(workspace_root, owner_unit, "feat-web", "web")
275
+ web_readme = feat_web_repo / "README.md"
276
+ web_readme.write_text(web_readme.read_text() + "\nexit should stash this\n")
277
+ pygr2("lane", "exit", str(workspace_root), owner_unit, "--actor", "human:layne")
278
+
279
+ sync_run = read_json(pygr2("sync", "run", str(workspace_root), "--dirty", "stash", "--json"))
280
+ dirty_issues = {item["code"] for item in sync_block["issues"]}
281
+ return {
282
+ "name": "dirty-state-and-recovery",
283
+ "holds": app_status["action"] == "block_dirty"
284
+ and app_status["status"]["dirty"] is True
285
+ and sync_block["status"] == "blocked"
286
+ and "dirty_shared_repo" in dirty_issues
287
+ and sync_run["status"] == "success"
288
+ and not bool(git("status", "--porcelain", cwd=shared_app).stdout.strip())
289
+ and len(stash_entries(shared_app)) >= 1
290
+ and not bool(git("status", "--porcelain", cwd=feat_web_repo).stdout.strip())
291
+ and len(stash_entries(feat_web_repo)) >= 1,
292
+ "payload": {
293
+ "repo_status": app_status,
294
+ "sync_block": sync_block,
295
+ "sync_run": sync_run,
296
+ "shared_stash": stash_entries(shared_app),
297
+ "lane_stash": stash_entries(feat_web_repo),
298
+ },
299
+ }
300
+
301
+
302
+ def main() -> int:
303
+ args = parse_args()
304
+ workspace_root = args.workspace_root.resolve()
305
+ ensure_workspace_root(workspace_root, keep_existing=args.keep_existing)
306
+ write_workspace_spec(workspace_root, args.owner_unit, args.workspace_name, args.transport)
307
+
308
+ results = [
309
+ scenario_real_remote_bootstrap(workspace_root, args.owner_unit, args.transport),
310
+ scenario_multi_lane_coexistence(workspace_root, args.owner_unit),
311
+ scenario_review_lane_isolation(workspace_root, args.owner_unit),
312
+ scenario_exec_status_honest(workspace_root, args.owner_unit),
313
+ scenario_dirty_state_and_recovery(workspace_root, args.owner_unit),
314
+ ]
315
+ verdict = "holds" if all(item["holds"] for item in results) else "gaps"
316
+ payload = {
317
+ "verdict": verdict,
318
+ "workspace_root": str(workspace_root),
319
+ "transport": args.transport,
320
+ "results": results,
321
+ }
322
+
323
+ if args.json:
324
+ print(json.dumps(payload, indent=2))
325
+ else:
326
+ print(f"real-git playground verdict: {verdict}")
327
+ print(f"workspace_root = {workspace_root}")
328
+ for item in results:
329
+ print(f"- {item['name']}: {'holds' if item['holds'] else 'gaps'}")
330
+ return 0 if verdict == "holds" else 1
331
+
332
+
333
+ if __name__ == "__main__":
334
+ raise SystemExit(main())