taskcarry 0.3.2__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 (105) hide show
  1. taskcarry/__init__.py +3 -0
  2. taskcarry/__main__.py +4 -0
  3. taskcarry/adapter_contracts.py +166 -0
  4. taskcarry/agy_turns.py +282 -0
  5. taskcarry/api.py +111 -0
  6. taskcarry/board.py +313 -0
  7. taskcarry/board_assets/board.css +1087 -0
  8. taskcarry/board_assets/board.js +1187 -0
  9. taskcarry/board_assets/browse.js +214 -0
  10. taskcarry/board_assets/index.html +43 -0
  11. taskcarry/board_assets/taskcarry-icon.ico +0 -0
  12. taskcarry/board_assets/taskcarry-mark.svg +28 -0
  13. taskcarry/board_data.py +466 -0
  14. taskcarry/chat_joins.py +157 -0
  15. taskcarry/cli.py +119 -0
  16. taskcarry/codex_capture.py +184 -0
  17. taskcarry/codex_host.py +293 -0
  18. taskcarry/collaboration_exchange.py +316 -0
  19. taskcarry/connection.py +159 -0
  20. taskcarry/continuity.py +300 -0
  21. taskcarry/contracts.py +165 -0
  22. taskcarry/conversation_capture.py +669 -0
  23. taskcarry/core.py +896 -0
  24. taskcarry/cycle_contracts.py +73 -0
  25. taskcarry/discovery.py +434 -0
  26. taskcarry/discovery_contracts.py +52 -0
  27. taskcarry/exchange_contracts.py +67 -0
  28. taskcarry/exchange_endpoint.py +377 -0
  29. taskcarry/exchange_packets.py +142 -0
  30. taskcarry/experience_contracts.py +129 -0
  31. taskcarry/experience_exchange.py +214 -0
  32. taskcarry/experience_notes.py +433 -0
  33. taskcarry/experience_storage.py +125 -0
  34. taskcarry/experience_tools.py +26 -0
  35. taskcarry/feishu/__init__.py +1 -0
  36. taskcarry/feishu/display.py +122 -0
  37. taskcarry/feishu/project_watch.py +145 -0
  38. taskcarry/feishu/review_sets.py +80 -0
  39. taskcarry/feishu/sender.py +42 -0
  40. taskcarry/feishu/subscription.py +193 -0
  41. taskcarry/feishu/windows_agent.py +287 -0
  42. taskcarry/feishu/windows_secret.py +34 -0
  43. taskcarry/gitops.py +170 -0
  44. taskcarry/governance.py +88 -0
  45. taskcarry/governance_cycle.py +775 -0
  46. taskcarry/identification.py +82 -0
  47. taskcarry/integration.py +663 -0
  48. taskcarry/maintenance.py +118 -0
  49. taskcarry/mcp.py +183 -0
  50. taskcarry/member_join.py +184 -0
  51. taskcarry/member_routing.py +145 -0
  52. taskcarry/onboarding.py +272 -0
  53. taskcarry/onboarding_complete.py +252 -0
  54. taskcarry/path_batches.py +19 -0
  55. taskcarry/preservation.py +257 -0
  56. taskcarry/project_collaboration.py +453 -0
  57. taskcarry/project_history.py +166 -0
  58. taskcarry/project_identity.py +51 -0
  59. taskcarry/project_recovery.py +824 -0
  60. taskcarry/recovery_contracts.py +25 -0
  61. taskcarry/recovery_files.py +153 -0
  62. taskcarry/recovery_git.py +234 -0
  63. taskcarry/remote_capture.py +89 -0
  64. taskcarry/remote_transfer.py +356 -0
  65. taskcarry/role_connection.py +215 -0
  66. taskcarry/setup.py +597 -0
  67. taskcarry/shared_workbench.py +480 -0
  68. taskcarry/skill_data/taskcarry-experience-recovery/SKILL.md +37 -0
  69. taskcarry/skill_data/taskcarry-governance-reconcile/SKILL.md +47 -0
  70. taskcarry/skill_data/taskcarry-governance-reconcile/references/daily-governance.md +72 -0
  71. taskcarry/skill_data/taskcarry-project-setup/SKILL.md +48 -0
  72. taskcarry/skill_data/taskcarry-project-setup/references/onboarding.md +198 -0
  73. taskcarry/skill_data/taskcarry-task-delivery/SKILL.md +32 -0
  74. taskcarry/skill_data/taskcarry-task-delivery/references/conditional-experience.md +93 -0
  75. taskcarry/skill_data/taskcarry-task-delivery/references/worker-channel.md +41 -0
  76. taskcarry/source_review_set.py +80 -0
  77. taskcarry/state_format.py +47 -0
  78. taskcarry/store.py +472 -0
  79. taskcarry/task_context.py +141 -0
  80. taskcarry/text_handback.py +98 -0
  81. taskcarry/transfer_contracts.py +18 -0
  82. taskcarry/updates.py +351 -0
  83. taskcarry/workbench.py +625 -0
  84. taskcarry/workbench_contracts.py +32 -0
  85. taskcarry/workbuddy_capture.py +451 -0
  86. taskcarry/workbuddy_setup.py +212 -0
  87. taskcarry/worker_channel.py +859 -0
  88. taskcarry/worker_contracts.py +190 -0
  89. taskcarry/worker_storage.py +60 -0
  90. taskcarry/worker_tools.py +111 -0
  91. taskcarry-0.3.2.dist-info/METADATA +203 -0
  92. taskcarry-0.3.2.dist-info/RECORD +105 -0
  93. taskcarry-0.3.2.dist-info/WHEEL +5 -0
  94. taskcarry-0.3.2.dist-info/entry_points.txt +5 -0
  95. taskcarry-0.3.2.dist-info/licenses/LICENSE +21 -0
  96. taskcarry-0.3.2.dist-info/licenses/LICENSE_SCOPE.md +31 -0
  97. taskcarry-0.3.2.dist-info/top_level.txt +2 -0
  98. taskcarry_https/__init__.py +1 -0
  99. taskcarry_https/consent.py +207 -0
  100. taskcarry_https/reader.py +132 -0
  101. taskcarry_https/review.py +116 -0
  102. taskcarry_https/server.py +163 -0
  103. taskcarry_https/team.py +335 -0
  104. taskcarry_https/team_host.py +109 -0
  105. taskcarry_https/web_host.py +82 -0
@@ -0,0 +1,663 @@
1
+ """Frozen delivery, exact local Git integration, WIP-safe adoption and recovery."""
2
+ from datetime import datetime, timezone
3
+ import json
4
+ import os
5
+ from pathlib import Path
6
+ import re
7
+
8
+ from .core import Core, validate_relative_path, read_file_bytes
9
+ from .store import GovernanceError
10
+ from . import __version__
11
+ from .gitops import (git, out, repo, commit, ancestor, pathsafe, changed, assert_tree_types,
12
+ identity, digest, fingerprint, clean, import_commit, Scratch)
13
+
14
+
15
+ def now():
16
+ return datetime.now(timezone.utc).isoformat()
17
+
18
+
19
+ def identifier(value):
20
+ if not isinstance(value, str) or not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_.-]{0,99}", value):
21
+ raise GovernanceError("INVALID_ID", "Use 1-100 letters, digits, underscores, dots or hyphens")
22
+ return value
23
+
24
+
25
+ class Integration:
26
+ OPERATION_PROTOCOL = 1
27
+
28
+ def __init__(self, project):
29
+ self.core = Core(project)
30
+ self.store = self.core.store
31
+ self.root = Path(project).resolve()
32
+ self.scratch = self.root / ".taskcarry" / "scratch"
33
+
34
+ def _save(self, collection, key, record):
35
+ if collection in {"operations", "plans"}:
36
+ self._check_protocol(record)
37
+ record.setdefault("operation_protocol", self.OPERATION_PROTOCOL)
38
+ record.setdefault("created_with_version", __version__)
39
+ self.store.put(collection, key, record)
40
+ return record
41
+
42
+ def _check_protocol(self, record):
43
+ # Records created before protocol tagging use the same version-one
44
+ # contract. A future contract must not be replayed by an older engine.
45
+ version = record.get("operation_protocol", 1)
46
+ if type(version) is not int or version != self.OPERATION_PROTOCOL:
47
+ raise GovernanceError("OPERATION_PROTOCOL_UNSUPPORTED", "Use a compatible toolkit to continue this recorded operation", {"operation_protocol": version})
48
+
49
+ def _ws(self, name):
50
+ record = self.store.get("workspaces", identifier(name))
51
+ if not record:
52
+ raise GovernanceError("WORKSPACE_UNKNOWN", "Register the workspace first", {"name": name})
53
+ path = repo(record["path"])
54
+ if identity(path) != record["identity"]:
55
+ raise GovernanceError("WORKSPACE_CHANGED", "Workspace branch or Git directory changed; explicitly re-register it")
56
+ return path
57
+
58
+ def workspace(self, name, path):
59
+ name = identifier(name)
60
+ p = repo(path)
61
+ if p.is_relative_to(self.root / ".taskcarry"):
62
+ raise GovernanceError("RESERVED_PATH", "Internal metadata cannot be a workspace")
63
+ ident = identity(p)
64
+ with self.store.transaction():
65
+ prior = self.store.get("workspaces", name)
66
+ if prior and prior["identity"] != ident:
67
+ pending = [s for s in self.store.list("stages") if s["workspace"] == name and s["status"] in {"QUEUED", "CONFLICT"}]
68
+ ops = [o for o in self.store.list("operations") if o.get("workspace") == name and o["status"] not in {"COMPLETED", "SUPERSEDED"}]
69
+ if pending or ops:
70
+ raise GovernanceError("WORKSPACE_IN_USE", "Finish or resolve existing operations before rebinding this name")
71
+ record = {"name": name, "path": str(p), "identity": ident}
72
+ self._save("workspaces", name, record)
73
+ self.store.event("workspace_registered", record)
74
+ return record
75
+
76
+ def submit(self, task_id, workspace, commit, base, paths, stage_id=None, relation="independent", supersedes=None):
77
+ task_id = identifier(task_id)
78
+ if not self.store.get("tasks", task_id):
79
+ raise GovernanceError("TASK_UNKNOWN", "Create a task before declaring a stable delivery")
80
+ source = self._ws(workspace)
81
+ # Avoid shadowing the public argument name.
82
+ from .gitops import commit as resolve_commit
83
+ tip, origin = resolve_commit(source, commit), resolve_commit(source, base)
84
+ if not ancestor(source, origin, tip) or origin == tip:
85
+ raise GovernanceError("INVALID_RANGE", "Base must be a strict ancestor of the submitted commit")
86
+ if not isinstance(paths, list) or not paths:
87
+ raise GovernanceError("EXACT_PATHS_REQUIRED", "Specify all changed paths in this stable stage")
88
+ exact = sorted({pathsafe(p) for p in paths})
89
+ if len(exact) != len(paths) or len({p.casefold() for p in exact}) != len(exact):
90
+ raise GovernanceError("DUPLICATE_PATH", "Duplicate or case-colliding paths")
91
+ actual = changed(source, origin, tip)
92
+ if actual != exact:
93
+ raise GovernanceError("MANIFEST_MISMATCH", "Declared paths must exactly match the frozen commit range", {"declared": exact, "actual": actual})
94
+ total_bytes = assert_tree_types(source, tip, exact) + assert_tree_types(source, origin, exact)
95
+ if total_bytes > 128 * 1024 * 1024:
96
+ raise GovernanceError("DELIVERY_TOO_LARGE", "Old and new delivery blobs exceed 128 MiB; use artifact references or smaller stages")
97
+ if relation not in {"independent", "cumulative"}:
98
+ raise GovernanceError("INVALID_RELATION", "Use independent or cumulative")
99
+ predecessors = sorted(set(supersedes or []))
100
+ if predecessors and relation != "cumulative":
101
+ raise GovernanceError("INVALID_RELATION", "Superseding requires an explicit cumulative relation")
102
+ if relation == "cumulative" and not predecessors:
103
+ raise GovernanceError("PREDECESSOR_REQUIRED", "Cumulative deliveries must name their predecessor stages")
104
+ body = {"task_id": task_id, "workspace": workspace, "commit": tip, "base": origin,
105
+ "paths": exact, "relation": relation, "supersedes": predecessors}
106
+ sid = identifier(stage_id or "stage-" + digest(body)[:20])
107
+ with self.store.transaction():
108
+ existing = self.store.get("stages", sid)
109
+ if existing:
110
+ if existing["declaration_hash"] != digest(body):
111
+ raise GovernanceError("ID_CONFLICT", "This stage id already describes a different delivery")
112
+ return {"stage": existing, "reused": True}
113
+ for old_id in predecessors:
114
+ old = self.store.get("stages", old_id)
115
+ if not old or old["task_id"] != task_id or old["workspace"] != workspace:
116
+ raise GovernanceError("INVALID_PREDECESSOR", "Predecessors must belong to the same task and workspace")
117
+ if old["status"] == "SUPERSEDED":
118
+ raise GovernanceError("INVALID_PREDECESSOR", "Name the current successor rather than an already superseded stage")
119
+ if not ancestor(source, old["commit"], tip) or not set(old["paths"]).issubset(exact):
120
+ raise GovernanceError("COVERAGE_UNPROVEN", "Cumulative stage must contain prior commit ancestry and declared paths")
121
+ record = {**body, "stage_id": sid, "status": "QUEUED", "declaration_hash": digest(body), "created_at": now()}
122
+ self._save("stages", sid, record)
123
+ self.store.event("stage_submitted", {"stage_id": sid, "task_id": task_id, "commit": tip})
124
+ return {"stage": record, "reused": False}
125
+
126
+ def _pending(self):
127
+ stages = self.store.list("stages")
128
+ values = [s for s in stages if s["status"] == "QUEUED"]
129
+ # A conflicting latest delivery must not silently reactivate an older
130
+ # candidate. Explicit lineage remains valid until explicitly resolved.
131
+ covered = {sid for s in stages for sid in s.get("supersedes", [])}
132
+ return sorted((s for s in values if s["stage_id"] not in covered), key=lambda x: (x["created_at"], x["stage_id"]))
133
+
134
+ def _predecessors(self, stage):
135
+ result, seen, remaining = [], set(), list(stage.get("supersedes", []))
136
+ while remaining:
137
+ sid = remaining.pop()
138
+ if sid in seen:
139
+ continue
140
+ seen.add(sid)
141
+ old = self.store.get("stages", sid)
142
+ if not old or old["task_id"] != stage["task_id"] or old["workspace"] != stage["workspace"]:
143
+ raise GovernanceError("INVALID_PREDECESSOR", "Stored predecessor chain is inconsistent")
144
+ result.append(old)
145
+ remaining.extend(old.get("supersedes", []))
146
+ return result
147
+
148
+ def _fault(self, requested, at):
149
+ if requested != at:
150
+ return
151
+ marker = self.root / ".taskcarry" / "SYNTHETIC_TEST_ONLY"
152
+ if os.environ.get("TASKCARRY_TEST_FAULTS") != "1" or not marker.is_file():
153
+ raise GovernanceError("FAULT_INJECTION_DISABLED", "Fault injection is restricted to explicitly marked synthetic tests")
154
+ raise GovernanceError("INJECTED_INTERRUPTION", "Synthetic interruption at " + at, {"point": at})
155
+
156
+ def _check_fault(self, fault):
157
+ if fault is not None and (os.environ.get("TASKCARRY_TEST_FAULTS") != "1" or not (self.root / ".taskcarry" / "SYNTHETIC_TEST_ONLY").is_file()):
158
+ raise GovernanceError("FAULT_INJECTION_DISABLED", "Fault injection is restricted to explicitly marked synthetic tests")
159
+
160
+ def _finish(self, operation, baseline):
161
+ self._check_protocol(operation)
162
+ stage = self.store.get("stages", operation["stage_id"])
163
+ candidate = operation["candidate"]
164
+ if not ancestor(baseline, candidate, commit(baseline, "HEAD")):
165
+ raise GovernanceError("EFFECT_NOT_CONFIRMED", "The frozen integration result is not present in the baseline")
166
+ if out(baseline, "rev-parse", candidate + "^{tree}") != operation["result_tree"]:
167
+ raise GovernanceError("EFFECT_MISMATCH", "Result tree differs from the journal")
168
+ with self.store.transaction():
169
+ stage.update({"status": "COMMITTED", "accepted_commit": candidate, "accepted_baseline": str(baseline), "accepted_at": now(), "operation_id": operation["operation_id"]})
170
+ self._save("stages", stage["stage_id"], stage)
171
+ for old in self._predecessors(stage):
172
+ old_id = old["stage_id"]
173
+ if old["status"] == "SUPERSEDED":
174
+ continue
175
+ old.update({"status": "SUPERSEDED", "successor": stage["stage_id"], "historical_status": old["status"]})
176
+ self._save("stages", old_id, old)
177
+ old_op = self.store.get("operations", old.get("operation_id", ""))
178
+ if old_op and old_op["status"] != "COMPLETED":
179
+ old_op.update({"historical_status": old_op["status"], "status": "COMPLETED", "resolved_by_successor": stage["stage_id"]})
180
+ self._save("operations", old_op["operation_id"], old_op)
181
+ operation.update({"status": "COMPLETED", "completed_at": now()})
182
+ self._save("operations", operation["operation_id"], operation)
183
+ self.store.event("stage_received", {"stage_id": stage["stage_id"], "result_commit": candidate, "integration_verified": True})
184
+ return {"stage_id": stage["stage_id"], "status": "COMMITTED", "commit": candidate, "integration_verified": True}
185
+
186
+ def _resume_receive(self, baseline, operation):
187
+ self._check_protocol(operation)
188
+ if identity(baseline) != operation["baseline_identity"]:
189
+ raise GovernanceError("WORKSPACE_CHANGED", "Original integration branch changed; no effects replayed")
190
+ candidate = operation.get("candidate")
191
+ if candidate and ancestor(baseline, candidate, commit(baseline, "HEAD")):
192
+ rules = self.core.match_experience("EFFECT_PRESENT_RECEIPT_MISSING", "reconcile", operation["task_id"])
193
+ if isinstance(rules, dict):
194
+ rules = rules.get("matches", rules.get("rules", []))
195
+ applicable = [r for r in rules if r.get("action") == "verify_and_finalize"]
196
+ if not applicable:
197
+ raise GovernanceError("EXPERIENCE_REVIEW_REQUIRED", "Effect is present; no currently applicable recovery rule permits automatic finalization", {"operation_id": operation["operation_id"]})
198
+ with self.store.transaction():
199
+ result = self._finish(operation, baseline)
200
+ self.store.event("experience_applied", {"rule_id": applicable[0]["rule_id"], "operation_id": operation["operation_id"], "effect_verified": True})
201
+ return {**result, "recovered": True, "experience_rule": applicable[0]["rule_id"]}
202
+ if candidate and commit(baseline, "HEAD") == operation["expected_head"] and clean(baseline):
203
+ git(baseline, "merge", "--ff-only", "--no-overwrite-ignore", "--no-edit", candidate)
204
+ return self._finish(operation, baseline)
205
+ if not candidate and commit(baseline, "HEAD") == operation["expected_head"]:
206
+ stage = self.store.get("stages", operation["stage_id"])
207
+ return self._receive(baseline, stage, operation["plan_id"], None, operation)
208
+ raise GovernanceError("RECOVERY_REVIEW_REQUIRED", "Baseline changed outside the recorded operation; completed effects will not be replayed", {"operation_id": operation["operation_id"]})
209
+
210
+ def _receive(self, baseline, stage, plan_id, fault, existing=None):
211
+ source = self._ws(stage["workspace"])
212
+ head = commit(baseline, "HEAD")
213
+ oid = "receive-" + digest({"stage": stage["stage_id"], "baseline": str(baseline)})[:24]
214
+ operation = existing or {"operation_id": oid, "kind": "reconcile", "stage_id": stage["stage_id"], "task_id": stage["task_id"],
215
+ "baseline": str(baseline), "baseline_identity": identity(baseline), "expected_head": head, "plan_id": plan_id, "status": "PREPARED", "created_at": now()}
216
+ self._save("operations", oid, operation)
217
+ import_commit(baseline, source, stage["commit"])
218
+ effective_base = stage["base"]
219
+ accepted = [s for s in self._predecessors(stage) if s.get("accepted_commit")]
220
+ # Among explicitly covered accepted predecessors choose the newest ancestor.
221
+ for old in accepted:
222
+ if old.get("accepted_baseline") == str(baseline) and ancestor(baseline, old["accepted_commit"], head) and ancestor(source, effective_base, old["commit"]):
223
+ effective_base = old["commit"]
224
+ delta = git(source, "diff", "--binary", "--full-index", "--no-renames", "--no-ext-diff", "--no-textconv", effective_base, stage["commit"], "--").stdout
225
+ with Scratch(baseline, self.scratch, head) as scratch:
226
+ if delta:
227
+ result = git(scratch, "apply", "--index", "--3way", "--whitespace=nowarn", "-", data=delta, check=False)
228
+ if result.returncode:
229
+ operation.update({"status": "REVIEW_REQUIRED", "code": "CONTENT_CONFLICT", "detail": result.stderr.decode("utf-8", "replace")})
230
+ self._save("operations", oid, operation)
231
+ stage.update({"status": "CONFLICT", "operation_id": oid})
232
+ self._save("stages", stage["stage_id"], stage)
233
+ raise GovernanceError("CONTENT_CONFLICT", "Frozen delivery conflicts with the current baseline; user work was not changed", {"stage_id": stage["stage_id"]})
234
+ tree = out(scratch, "write-tree")
235
+ message = f"Receive stage {stage['stage_id']}\n\nTaskCarry-Operation: {oid}\nTaskCarry-Source: {stage['commit']}\n"
236
+ candidate = git(scratch, "commit-tree", tree, "-p", head, data=message.encode()).stdout.decode().strip()
237
+ operation.update({"candidate": candidate, "result_tree": tree, "status": "CANDIDATE_READY", "effective_base": effective_base})
238
+ self._save("operations", oid, operation)
239
+ self._fault(fault, "after_candidate")
240
+ if identity(baseline) != operation["baseline_identity"] or commit(baseline, "HEAD") != head or not clean(baseline):
241
+ raise GovernanceError("BASELINE_CHANGED", "Baseline changed while preparing the result; the candidate is retained")
242
+ git(baseline, "merge", "--ff-only", "--no-overwrite-ignore", "--no-edit", candidate)
243
+ operation["status"] = "EFFECT_APPLIED"
244
+ self._save("operations", oid, operation)
245
+ self._fault(fault, "after_effect")
246
+ return self._finish(operation, baseline)
247
+
248
+ def _receive_selection(self, outstanding, stages, limit):
249
+ # Recovery comes first. An operation and its queued stage are one work
250
+ # item, even though both identities belong in the frozen plan.
251
+ groups = {}
252
+ for op in sorted(outstanding, key=lambda o: (o.get("created_at", ""), o["operation_id"])):
253
+ key = ("stage", op["stage_id"]) if op.get("stage_id") else ("operation", op["operation_id"])
254
+ groups.setdefault(key, {"operations": [], "stage": None})["operations"].append(op)
255
+ for stage in stages:
256
+ groups.setdefault(("stage", stage["stage_id"]), {"operations": [], "stage": None})["stage"] = stage
257
+ selected = list(groups.values())[:limit]
258
+ return ([op for group in selected for op in group["operations"]],
259
+ [group["stage"] for group in selected if group["stage"] is not None],
260
+ {"limit": limit, "selected_count": len(selected), "available_count": len(groups),
261
+ "unselected_count": len(groups) - len(selected)})
262
+
263
+ def _receive_receipt(self, plan, results, reused=False):
264
+ current = self.core.status()
265
+ scoped_operations = set(plan.get("pending_operations", []))
266
+ scoped_stages = set(plan["stage_ids"])
267
+ operations = [o for o in current["actionable"]["operations"]
268
+ if o["operation_id"] in scoped_operations or o.get("plan_id") == plan["plan_id"]]
269
+ unfinished = [s["stage_id"] for s in current["stages"]
270
+ if s["stage_id"] in scoped_stages and s["status"] not in {"COMMITTED", "SUPERSEDED"}]
271
+ conflicts = [{"stage_id": s["stage_id"], "code": "CONTENT_CONFLICT"}
272
+ for s in current["stages"] if s["status"] == "CONFLICT"]
273
+ queued = [s["stage_id"] for s in current["actionable"]["stages"] if s["status"] == "QUEUED"]
274
+ unselected = [sid for sid in queued if sid not in scoped_stages]
275
+ selected_operation_ids = {o["operation_id"] for o in operations}
276
+ return {"status": "ACTION_REQUIRED" if conflicts or unfinished or operations else "COMPLETE",
277
+ "scope": "plan", "plan_id": plan["plan_id"], "plan_complete": not unfinished and not operations,
278
+ "project_complete": None, "results": results, "reused": reused, "remaining": conflicts,
279
+ "remaining_stage_ids": unfinished, "remaining_operation_ids": [o["operation_id"] for o in operations],
280
+ "queued_stage_ids": queued, "unselected_queued_stage_ids": unselected,
281
+ "unselected_operation_ids": [o["operation_id"] for o in current["actionable"]["operations"]
282
+ if o["operation_id"] not in selected_operation_ids],
283
+ "current_actionable_counts": {name: len(records) for name, records in current["actionable"].items()},
284
+ "meaning": "Completion covers only this frozen plan. Other recorded work and business acceptance require separate assessment."}
285
+
286
+ def reconcile(self, baseline, execute=False, plan_id=None, fault=None, limit=20):
287
+ if type(limit) is not int or not 1 <= limit <= 100:
288
+ raise GovernanceError("INVALID_ARGUMENT", "Reconciliation limit must be an integer from 1 to 100")
289
+ self._check_fault(fault)
290
+ with self.store.guard():
291
+ recovery_binding = self.store.get("settings", "integration_baseline_recovery") or {}
292
+ if recovery_binding.get("status") == "REBIND_REQUIRED":
293
+ raise GovernanceError("RECOVERY_BASELINE_REBIND_REQUIRED", "The restored set omitted the bound baseline or its unique source identity; restore a complete reviewed set before receiving stages", recovery_binding)
294
+ target = self._ws(baseline)
295
+ binding = self.store.get("settings", "integration_baseline")
296
+ if binding and binding != identity(target):
297
+ raise GovernanceError("BASELINE_BOUND", "This state source already has an integration baseline; route another baseline to its own state source without redefining the user's project")
298
+ outstanding = [o for o in self.store.list("operations") if o.get("kind") == "reconcile" and o.get("baseline") == str(target) and o["status"] not in {"COMPLETED", "REVIEW_REQUIRED", "SUPERSEDED"} and not o.get("recovery_inert")]
299
+ if not execute:
300
+ selected_ops, stages, selection = self._receive_selection(outstanding, self._pending(), limit)
301
+ conflicts = [{"stage_id": s["stage_id"], "code": "CONTENT_CONFLICT"} for s in self.store.list("stages") if s["status"] == "CONFLICT"]
302
+ data = {"kind": "reconcile", "baseline": baseline, "head": commit(target, "HEAD"), "stage_ids": [s["stage_id"] for s in stages], "declarations": {s["stage_id"]: s["declaration_hash"] for s in stages}, "unresolved": conflicts,
303
+ "pending_operations": [o["operation_id"] for o in selected_ops], "selection": selection}
304
+ config = self.store.get("config", "project") or {}
305
+ if config.get("recovery_restore_id"):
306
+ data["recovery_context"] = {"restore_id": config["recovery_restore_id"], "replica_id": config["replica_id"]}
307
+ pid = "plan-" + digest(data)[:24]
308
+ plan = self.store.get("plans", pid)
309
+ if plan is None:
310
+ plan = {**data, "plan_id": pid, "created_at": now()}
311
+ self._save("plans", pid, plan)
312
+ return {"plan": plan, "effects_executed": False, "clean_baseline": clean(target)}
313
+ if not plan_id:
314
+ raise GovernanceError("PLAN_REQUIRED", "Review a persisted reconciliation plan before execution")
315
+ plan = self.store.get("plans", plan_id)
316
+ if not plan or plan["kind"] != "reconcile" or plan["baseline"] != baseline:
317
+ raise GovernanceError("PLAN_MISMATCH", "Plan does not describe this baseline")
318
+ self._check_protocol(plan)
319
+ for op in self.store.list("operations"):
320
+ if op.get("plan_id") == plan_id or op.get("operation_id") in plan.get("pending_operations", []):
321
+ self._check_protocol(op)
322
+ for sid in plan["stage_ids"]:
323
+ stage = self.store.get("stages", sid)
324
+ if stage:
325
+ for related in [stage, *self._predecessors(stage)]:
326
+ op = self.store.get("operations", related.get("operation_id", ""))
327
+ if op:
328
+ self._check_protocol(op)
329
+ results = []
330
+ for op in outstanding:
331
+ if op["plan_id"] == plan_id or op["operation_id"] in plan.get("pending_operations", []):
332
+ results.append(self._resume_receive(target, op))
333
+ completed_ops = [o for o in self.store.list("operations") if o.get("kind") == "reconcile" and o.get("candidate") and (o.get("plan_id") == plan_id or o["operation_id"] in plan.get("pending_operations", [])) and o["status"] == "COMPLETED"]
334
+ expected = completed_ops[-1]["candidate"] if completed_ops else plan["head"]
335
+ # Store list ordering is unspecified; chain last completed result by ancestry.
336
+ for op in completed_ops:
337
+ if ancestor(target, expected, op["candidate"]):
338
+ expected = op["candidate"]
339
+ unfinished = [sid for sid in plan["stage_ids"] if self.store.get("stages", sid)["status"] not in {"COMMITTED", "SUPERSEDED"}]
340
+ if not unfinished:
341
+ return self._receive_receipt(plan, results, reused=not results)
342
+ if commit(target, "HEAD") != expected:
343
+ raise GovernanceError("STALE_BASELINE", "Baseline advanced since this plan; create a new plan", {"expected": expected, "actual": commit(target, "HEAD")})
344
+ if not clean(target):
345
+ raise GovernanceError("BASELINE_WIP", "Use a dedicated clean integration workspace; ordinary worker WIP remains untouched")
346
+ if not binding:
347
+ self._save("settings", "integration_baseline", identity(target))
348
+ errors = []
349
+ for sid in unfinished:
350
+ stage = self.store.get("stages", sid)
351
+ if stage["declaration_hash"] != plan["declarations"][sid]:
352
+ raise GovernanceError("DECLARATION_CHANGED", "Stage no longer matches the reviewed plan")
353
+ if stage["status"] == "CONFLICT":
354
+ errors.append({"stage_id": sid, "code": "CONTENT_CONFLICT"})
355
+ continue
356
+ try:
357
+ results.append(self._receive(target, stage, plan_id, fault))
358
+ except GovernanceError as exc:
359
+ if exc.code != "CONTENT_CONFLICT":
360
+ raise
361
+ errors.append({"stage_id": sid, "code": exc.code})
362
+ return self._receive_receipt(plan, results)
363
+
364
+ def _restore_planned_bytes(self, workspace, operation):
365
+ """Correct only proven checkout newline conversion, never new content.
366
+
367
+ Git's clean/smudge conversion can change WIP bytes even when its diff is
368
+ identical. Use the frozen result, check every affected file first, and
369
+ preserve the exact index. This is not a general overwrite/recovery path.
370
+ """
371
+ references = operation.get("expected_worktree_bytes")
372
+ if references is None:
373
+ # Upgrade an old journal only where its checkpoint proves the exact
374
+ # untracked content; do not infer merged tracked bytes from history.
375
+ checkpoint = self.store.get("checkpoints", operation.get("checkpoint_id", ""))
376
+ references = {f["path"]: f["worktree"] for f in (checkpoint or {}).get("files", [])
377
+ if f["path"] in operation["before"]["untracked"]}
378
+ actual, expected = fingerprint(workspace), operation["expected_result"]
379
+ if any(actual[k] != expected[k] for k in ("head", "status", "index", "work_diff")):
380
+ return False
381
+ if set(actual["untracked"]) != set(expected["untracked"]):
382
+ return False
383
+ pending = []
384
+ for rel, reference in references.items():
385
+ path = validate_relative_path(workspace, rel)
386
+ if reference is None:
387
+ if path.exists():
388
+ return False
389
+ continue
390
+ if not path.is_file():
391
+ return False
392
+ wanted, present = self.core._snapshot_bytes(reference), read_file_bytes(path)
393
+ if wanted == present:
394
+ continue
395
+ if b"\0" in wanted or b"\0" in present or wanted.replace(b"\r\n", b"\n") != present.replace(b"\r\n", b"\n"):
396
+ return False
397
+ pending.append((path, present, wanted))
398
+ if any(value != expected["untracked"][rel] for rel, value in actual["untracked"].items() if rel not in references):
399
+ return False
400
+ for path, present, wanted in pending:
401
+ # Recheck through the same handle before replacing these known bytes.
402
+ with path.open("r+b") as stream:
403
+ if stream.read() != present:
404
+ raise GovernanceError("SOURCE_CHANGED", "Work changed during byte restoration; retained backups remain available")
405
+ stream.seek(0)
406
+ stream.write(wanted)
407
+ stream.truncate()
408
+ stream.flush()
409
+ os.fsync(stream.fileno())
410
+ if pending:
411
+ self.store.event("worktree_bytes_restored", {"operation_id": operation["operation_id"], "files": len(pending), "reason": "verified_newline_conversion"})
412
+ return True
413
+
414
+ def _adopt_finish(self, workspace, operation):
415
+ self._check_protocol(operation)
416
+ bytes_verified = self._restore_planned_bytes(workspace, operation)
417
+ if not bytes_verified or fingerprint(workspace) != operation["expected_result"]:
418
+ raise GovernanceError("WIP_RESTORE_REQUIRED", "Workspace does not match the prevalidated restored state; retained checkpoint and stash need review", {"operation_id": operation["operation_id"], "stash": operation.get("stash"), "checkpoint_id": operation.get("checkpoint_id")})
419
+ with self.store.transaction():
420
+ operation.update({"status": "COMPLETED", "effect_state": "VERIFIED", "completed_at": now()})
421
+ self._save("operations", operation["operation_id"], operation)
422
+ self._resolve_adoption_preparations(operation)
423
+ self.store.event("workspace_adopted", {"operation_id": operation["operation_id"], "workspace": operation["workspace"], "wip_verified": True})
424
+ return {"status": "ADOPTED", "workspace": operation["workspace"], "commit": operation["candidate"], "wip_verified": True,
425
+ "retained_backup_stash": operation.get("stash"), "checkpoint_id": operation.get("checkpoint_id")}
426
+
427
+ def _resolve_adoption_preparations(self, operation):
428
+ # Only a reviewed successor plan and verified adoption retire prior
429
+ # no-effect preparations. The original failure evidence stays intact.
430
+ for oid in operation.get("resolves_preparation_failures", []):
431
+ old = self.store.get("operations", oid)
432
+ if (not old or old.get("kind") != "adopt" or old.get("workspace") != operation["workspace"]
433
+ or old.get("baseline") != operation.get("baseline")
434
+ or old.get("status") not in {"PREPARING", "PREPARATION_FAILED"}
435
+ or old.get("effect_state") != "NOT_APPLIED" or old.get("candidate") or old.get("stash")):
436
+ continue
437
+ old.update({"historical_status": old["status"], "status": "SUPERSEDED",
438
+ "resolved_by_operation": operation["operation_id"], "resolved_by_plan": operation["plan_id"]})
439
+ self._save("operations", oid, old)
440
+ self.store.event("adoption_preparation_superseded", {"operation_id": oid, "successor": operation["operation_id"]})
441
+
442
+ def _adoption_failure(self, operation, exc):
443
+ failure = {"code": getattr(exc, "code", "PREPARATION_FAILED"), "message": str(exc),
444
+ "details": getattr(exc, "details", None)}
445
+ first_failure = "first_failure" not in operation
446
+ operation.setdefault("first_failure", failure)
447
+ operation.update({"status": "PREPARATION_FAILED", "phase": "preparation", "effect_state": "NOT_APPLIED",
448
+ "code": failure["code"], "last_failure": failure})
449
+ self._save("operations", operation["operation_id"], operation)
450
+ # One durable attempt per plan, with bounded first/last diagnostics.
451
+ # Repeated errors may contain fresh scratch paths; they are not new work.
452
+ if first_failure:
453
+ self.store.event("adoption_preparation_failed", {"operation_id": operation["operation_id"], **failure})
454
+
455
+ def _adopt_resume(self, target, operation):
456
+ self._check_protocol(operation)
457
+ if fingerprint(target) == operation.get("expected_result"):
458
+ return self._adopt_finish(target, operation)
459
+ candidate = operation.get("candidate")
460
+ if not candidate:
461
+ raise GovernanceError("RECOVERY_REVIEW_REQUIRED", "Incomplete adoption preparation has no frozen candidate")
462
+ if commit(target, "HEAD") == candidate and not clean(target):
463
+ # A prior apply may have finished except for exact byte verification.
464
+ # Check it once; never repeat stash application over present WIP.
465
+ return self._adopt_finish(target, operation)
466
+ stash = operation.get("stash")
467
+ if operation.get("has_wip") and not stash:
468
+ for row in out(target, "stash", "list", "--format=%H%x09%gs").splitlines():
469
+ sha, _, subject = row.partition("\t")
470
+ if subject.endswith("taskcarry:" + operation["operation_id"]):
471
+ stash = sha
472
+ operation["stash"] = sha
473
+ self._save("operations", operation["operation_id"], operation)
474
+ break
475
+ if operation.get("has_wip") and not stash and fingerprint(target) == operation.get("before"):
476
+ git(target, "stash", "push", "--include-untracked", "-m", "taskcarry:" + operation["operation_id"])
477
+ stash = out(target, "rev-parse", "refs/stash")
478
+ operation["stash"] = stash
479
+ self._save("operations", operation["operation_id"], operation)
480
+ if not clean(target):
481
+ raise GovernanceError("RECOVERY_REVIEW_REQUIRED", "Unexpected work appeared during adoption; it is preserved")
482
+ head = commit(target, "HEAD")
483
+ if head == operation["expected_head"]:
484
+ git(target, "merge", "--ff-only", "--no-overwrite-ignore", "--no-edit", candidate)
485
+ elif head != candidate:
486
+ raise GovernanceError("RECOVERY_REVIEW_REQUIRED", "Branch changed during adoption; retained WIP will not be replayed")
487
+ if operation.get("has_wip"):
488
+ if not stash:
489
+ raise GovernanceError("WIP_RESTORE_REQUIRED", "Expected backup stash is not found; use retained checkpoint")
490
+ git(target, "stash", "apply", "--index", stash)
491
+ return self._adopt_finish(target, operation)
492
+
493
+ def _prepare_adoption(self, target, source, plan, op):
494
+ workspace = op["workspace"]
495
+ before = plan["before"]
496
+ staged = git(target, "diff", "--cached", "--binary", "--full-index", "--no-ext-diff", "--no-textconv", "--").stdout
497
+ unstaged = git(target, "diff", "--binary", "--full-index", "--no-ext-diff", "--no-textconv", "--").stdout
498
+ untracked = {rel: (target / rel).read_bytes() for rel in before["untracked"]}
499
+ dirty_paths = set(git(target, "diff", "--cached", "--name-only", "-z", "--").stdout.decode().strip("\0").split("\0")) - {""}
500
+ dirty_paths.update(set(git(target, "diff", "--name-only", "-z", "--").stdout.decode().strip("\0").split("\0")) - {""})
501
+ dirty_paths.update(untracked)
502
+ checkpoint_id = op.get("checkpoint_id")
503
+ checkpoint = self.store.get("checkpoints", checkpoint_id) if checkpoint_id else None
504
+ if checkpoint_id and checkpoint is None:
505
+ raise GovernanceError("RECOVERY_REVIEW_REQUIRED", "The retained preparation checkpoint is missing")
506
+ if dirty_paths and checkpoint is None:
507
+ for rel in dirty_paths:
508
+ pathsafe(rel)
509
+ backup_task = "adoption-backup-" + workspace
510
+ self.core.task(backup_task, title="Retained workspace update checkpoint", state="paused")
511
+ checkpoint = self.core.checkpoint(backup_task, str(target), sorted(dirty_paths), "Continue original work after public baseline update", decision="Technical preservation only; not a new delivery", paused=True)
512
+ checkpoint_id = checkpoint.get("checkpoint_id") or checkpoint.get("checkpoint", {}).get("checkpoint_id")
513
+ op["checkpoint_id"] = checkpoint_id
514
+ self._save("operations", op["operation_id"], op)
515
+ import_commit(target, source, plan["baseline_head"])
516
+ with Scratch(target, self.scratch, before["head"]) as scratch:
517
+ merge = git(scratch, "merge", "--no-edit", plan["baseline_head"], check=False)
518
+ if merge.returncode:
519
+ raise GovernanceError("ADOPTION_CONFLICT", "Local commits conflict with the public baseline; original workspace remains unchanged")
520
+ candidate = commit(scratch, "HEAD")
521
+ changed_paths = changed(scratch, before["head"], candidate)
522
+ assert_tree_types(scratch, candidate, changed_paths)
523
+ for rel in changed_paths:
524
+ pathsafe(rel)
525
+ was_tracked = bool(git(target, "ls-tree", "-z", before["head"], "--", rel).stdout)
526
+ if not was_tracked and (target / rel).exists() and rel not in untracked:
527
+ raise GovernanceError("IGNORED_FILE_COLLISION", "A local ignored file or directory overlaps the new baseline; it was not changed", {"path": rel})
528
+ if staged:
529
+ cp = git(scratch, "apply", "--index", "--3way", "--whitespace=nowarn", "-", data=staged, check=False)
530
+ if cp.returncode:
531
+ raise GovernanceError("WIP_CONFLICT", "Staged changes need review against the new baseline; original WIP retained")
532
+ if unstaged:
533
+ cp = git(scratch, "apply", "--whitespace=nowarn", "-", data=unstaged, check=False)
534
+ if cp.returncode:
535
+ raise GovernanceError("WIP_CONFLICT", "Unstaged changes need review against the new baseline; original WIP retained")
536
+ for rel, payload in untracked.items():
537
+ dest = scratch / pathsafe(rel)
538
+ if dest.exists():
539
+ raise GovernanceError("WIP_CONFLICT", "Untracked file would collide with a baseline file", {"path": rel})
540
+ dest.parent.mkdir(parents=True, exist_ok=True)
541
+ dest.write_bytes(payload)
542
+ # Preserve raw WIP bytes where adoption did not change that file.
543
+ # For a merged file the isolated candidate defines its new bytes.
544
+ for record in (checkpoint or {}).get("files", []):
545
+ if record["path"] not in changed_paths and record["worktree"] is not None:
546
+ dest = validate_relative_path(scratch, record["path"])
547
+ dest.write_bytes(self.core._snapshot_bytes(record["worktree"]))
548
+ expected_bytes = {}
549
+ for rel in sorted(dirty_paths):
550
+ dest = validate_relative_path(scratch, rel)
551
+ expected_bytes[rel] = self.core._snapshot(read_file_bytes(dest)) if dest.is_file() else None
552
+ expected = fingerprint(scratch)
553
+ if identity(target) != self.store.get("workspaces", workspace)["identity"] or fingerprint(target) != before:
554
+ raise GovernanceError("WORKSPACE_CHANGED", "Workspace changed during adoption preparation")
555
+ has_wip = bool(before["status"])
556
+ op.update({"status": "CANDIDATE_READY", "phase": "prepared", "candidate": candidate,
557
+ "expected_result": expected, "has_wip": has_wip, "checkpoint_id": checkpoint_id})
558
+ op["expected_worktree_bytes"] = expected_bytes
559
+ self._save("operations", op["operation_id"], op)
560
+ return op
561
+
562
+ def adopt(self, workspace, baseline, execute=False, plan_id=None, fault=None):
563
+ self._check_fault(fault)
564
+ target, source = self._ws(workspace), self._ws(baseline)
565
+ if target == source:
566
+ raise GovernanceError("SAME_WORKSPACE", "Baseline cannot adopt itself")
567
+ with self.store.guard():
568
+ if not execute:
569
+ data = {"kind": "adopt", "workspace": workspace, "baseline": baseline, "baseline_head": commit(source, "HEAD"), "before": fingerprint(target)}
570
+ config = self.store.get("config", "project") or {}
571
+ if config.get("recovery_restore_id"):
572
+ data["recovery_context"] = {"restore_id": config["recovery_restore_id"], "replica_id": config["replica_id"]}
573
+ failures = [o["operation_id"] for o in self.store.list("operations")
574
+ if o.get("kind") == "adopt" and o.get("workspace") == workspace and o.get("baseline") == baseline
575
+ and o.get("status") in {"PREPARING", "PREPARATION_FAILED"}
576
+ and o.get("effect_state") == "NOT_APPLIED" and not o.get("candidate") and not o.get("stash")
577
+ and (o.get("before") != data["before"] or o.get("baseline_head") != data["baseline_head"])]
578
+ if failures:
579
+ data["resolves_preparation_failures"] = failures
580
+ pid = "adopt-plan-" + digest(data)[:24]
581
+ plan = self.store.get("plans", pid)
582
+ if plan is None:
583
+ plan = {**data, "plan_id": pid, "created_at": now()}
584
+ self._save("plans", pid, plan)
585
+ return {"plan": plan, "effects_executed": False}
586
+ plan = self.store.get("plans", plan_id) if plan_id else None
587
+ if not plan or plan["kind"] != "adopt" or plan["workspace"] != workspace or plan["baseline"] != baseline:
588
+ raise GovernanceError("PLAN_REQUIRED", "Use the exact adoption plan for this workspace")
589
+ self._check_protocol(plan)
590
+ for old_id in plan.get("resolves_preparation_failures", []):
591
+ previous = self.store.get("operations", old_id)
592
+ if previous:
593
+ self._check_protocol(previous)
594
+ oid = "adopt-" + digest(plan_id)[:24]
595
+ op = self.store.get("operations", oid)
596
+ if op:
597
+ self._check_protocol(op)
598
+ if op["status"] == "COMPLETED":
599
+ self._resolve_adoption_preparations(op)
600
+ return {"status": "ADOPTED", "reused": True, "workspace": workspace, "commit": op["candidate"]}
601
+ if op["status"] == "SUPERSEDED":
602
+ raise GovernanceError("OPERATION_SUPERSEDED", "A verified successor resolved this failed preparation; use its receipt", {"operation_id": oid, "resolved_by_operation": op.get("resolved_by_operation")})
603
+ if (op.get("effect_state") != "NOT_APPLIED" or op.get("candidate") or op.get("stash")
604
+ or op.get("status") not in {"PREPARING", "PREPARATION_FAILED"}):
605
+ return self._adopt_resume(target, op)
606
+ if fingerprint(target) != plan["before"] or commit(source, "HEAD") != plan["baseline_head"]:
607
+ raise GovernanceError("STALE_PLAN", "Work or baseline changed; create a new adoption plan")
608
+ if op is None:
609
+ op = {"operation_id": oid, "kind": "adopt", "workspace": workspace, "baseline": baseline,
610
+ "baseline_head": plan["baseline_head"], "plan_id": plan_id, "status": "PREPARING",
611
+ "phase": "preparation", "effect_state": "NOT_APPLIED", "before": plan["before"],
612
+ "expected_head": plan["before"]["head"], "created_at": now(),
613
+ "resolves_preparation_failures": plan.get("resolves_preparation_failures", [])}
614
+ # An unchanged WIP snapshot may be reused even when the source
615
+ # baseline moved and the new plan supersedes a failed attempt.
616
+ for old_id in op["resolves_preparation_failures"]:
617
+ old = self.store.get("operations", old_id)
618
+ if old and old.get("before") == plan["before"] and old.get("checkpoint_id"):
619
+ op["checkpoint_id"] = old["checkpoint_id"]
620
+ break
621
+ self._save("operations", oid, op)
622
+ try:
623
+ op = self._prepare_adoption(target, source, plan, op)
624
+ except Exception as exc:
625
+ self._adoption_failure(op, exc)
626
+ raise
627
+ has_wip = op["has_wip"]
628
+ candidate = op["candidate"]
629
+ if has_wip:
630
+ git(target, "stash", "push", "--include-untracked", "-m", "taskcarry:" + oid)
631
+ op["stash"] = out(target, "rev-parse", "refs/stash")
632
+ op["status"] = "WIP_SAVED"
633
+ op["effect_state"] = "WIP_SAVED"
634
+ self._save("operations", oid, op)
635
+ self._fault(fault, "after_stash")
636
+ git(target, "merge", "--ff-only", "--no-overwrite-ignore", "--no-edit", candidate)
637
+ op["status"] = "EFFECT_APPLIED"
638
+ op["effect_state"] = "APPLIED"
639
+ self._save("operations", oid, op)
640
+ self._fault(fault, "after_adopt")
641
+ if has_wip:
642
+ git(target, "stash", "apply", "--index", op["stash"])
643
+ self._fault(fault, "after_restore")
644
+ return self._adopt_finish(target, op)
645
+
646
+ def doctor(self):
647
+ import platform
648
+ from .setup import runtime_info
649
+ try:
650
+ version = out(self.root, "--version")
651
+ git_status = "AVAILABLE"
652
+ except GovernanceError:
653
+ version, git_status = None, "UNAVAILABLE"
654
+ checks = []
655
+ for ws in self.store.list("workspaces"):
656
+ try:
657
+ self._ws(ws["name"])
658
+ checks.append({"workspace": ws["name"], "status": "AVAILABLE"})
659
+ except GovernanceError as exc:
660
+ checks.append({"workspace": ws["name"], "status": "ACTION_REQUIRED", "code": exc.code})
661
+ return {"toolkit_version": __version__, "python": platform.python_version(), "platform": platform.system(), "git": {"status": git_status, "version": version}, "workspaces": checks,
662
+ "runtime": runtime_info(self.root),
663
+ "native_codex_connection": "VERIFY_IN_TARGET_HOST", "remote_push_supported": False, "multi_host_writer_supported": False}