Skip to content

Commit 02058b7

Browse files
chore: close audit cleanup and clean-room install fix
1 parent 9eed51e commit 02058b7

File tree

7 files changed

+52
-14
lines changed

7 files changed

+52
-14
lines changed

agents/main/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ Public role:
77

88
Private-only items that must not be copied here:
99
- personal identity details
10-
- private family routing
10+
- private household routing
1111
- private Telegram/WhatsApp doctrine

docs/EXTRACTION-MAP.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ Classification:
3030

3131
### Rewrite
3232

33-
- dist patch ledger shape from `/root/.openclaw/patches/apply-patches.sh`
33+
- dist patch ledger shape from the private runtime patch ledger
3434
- patch application helpers that currently assume the private compiled dist path
3535
- pre-start sync helpers such as `workspace/scripts/sync_agent_main_thinking.py`
36-
- any control-plane helper that assumes live session stores under `/root/.openclaw/agents/`
36+
- any control-plane helper that assumes live session stores under the private runtime root
3737

3838
### Exclude
3939

@@ -94,9 +94,9 @@ Classification:
9494

9595
### Exclude
9696

97-
- `/root/.openclaw/memory/main.sqlite`
97+
- live Tier 1 SQLite stores
9898
- live graph stores and caches
99-
- `/root/.openclaw/arscontexta/`
99+
- live synthesis stores
100100
- private operator memory and live episodic traces
101101

102102
## Operational Fabric

fixtures/ops_fabric/system-operational-watchdog.sample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"candidates": 1,
1010
"dispatches": 1,
1111
"deliverableActivity": 1,
12-
"normalizedPrincipalVisibleTasks": 1,
12+
"normalizedOwnerVisibleTasks": 1,
1313
"resolved": 0
1414
},
1515
"incidents": {

src/hyperclaw_max/first_run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ def run_first_run(
103103
def main() -> int:
104104
ap = argparse.ArgumentParser(description="Run the public HyperClaw-Max first-run bootstrap")
105105
ap.add_argument("target_root", type=Path, help="Destination root for the materialized public pack")
106-
ap.add_argument("--repo", type=Path, default=repo_root())
106+
ap.add_argument("--repo", type=Path, default=None)
107107
ap.add_argument("--include-optional", action="append", default=[], help="Optional agent id to materialize")
108108
ap.add_argument("--all-optional", action="store_true", help="Materialize all optional overlay agents")
109109
ap.add_argument("--force", action="store_true", help="Overwrite existing materialized files")
110110
ap.add_argument("--format", choices=["json", "human"], default="human")
111111
args = ap.parse_args()
112112

113113
payload = run_first_run(
114-
args.repo,
114+
args.repo.resolve() if args.repo is not None else repo_root(),
115115
args.target_root,
116116
include_optional=set(args.include_optional),
117117
include_all_optional=args.all_optional,

src/hyperclaw_max/materialize_pack.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,35 @@
1313
BOOT_FILES = ("README.md", "AGENTS.md", "BOOTSTRAP.md", "TOOLS.md")
1414
LIST_SECTIONS = {"required_agents", "optional_agents", "pack_rules"}
1515
REQUIRED_MANIFEST_KEYS = {"version", "name", "status", "required_agents", "optional_agents", "pack_rules"}
16+
REPO_ROOT_MARKERS = (
17+
"pyproject.toml",
18+
"agents/PACK-MANIFEST.yaml",
19+
"config/openclaw.public.example.jsonc",
20+
)
1621

1722

18-
def repo_root() -> Path:
19-
return Path(__file__).resolve().parents[2]
23+
def looks_like_repo_root(path: Path) -> bool:
24+
return all((path / marker).exists() for marker in REPO_ROOT_MARKERS)
25+
26+
27+
def repo_root(cwd: Path | None = None, module_path: Path | None = None) -> Path:
28+
candidates: list[Path] = []
29+
if cwd is not None:
30+
candidates.append(cwd.resolve())
31+
else:
32+
candidates.append(Path.cwd().resolve())
33+
34+
source_path = module_path.resolve() if module_path is not None else Path(__file__).resolve()
35+
candidates.extend(source_path.parents)
36+
37+
seen: set[Path] = set()
38+
for candidate in candidates:
39+
if candidate in seen:
40+
continue
41+
seen.add(candidate)
42+
if looks_like_repo_root(candidate):
43+
return candidate
44+
raise FileNotFoundError("Unable to locate the HyperClaw-Max repository root; pass --repo explicitly.")
2045

2146

2247
def now_iso() -> str:
@@ -205,15 +230,15 @@ def materialize_pack(
205230
def main() -> int:
206231
ap = argparse.ArgumentParser(description="Materialize the public HyperClaw-Max pack over a target root")
207232
ap.add_argument("target_root", type=Path, help="Destination root that will host config, workspaces, and runtime state")
208-
ap.add_argument("--repo", type=Path, default=repo_root())
233+
ap.add_argument("--repo", type=Path, default=None)
209234
ap.add_argument("--include-optional", action="append", default=[], help="Optional agent id to materialize")
210235
ap.add_argument("--all-optional", action="store_true", help="Materialize all optional overlay agents")
211236
ap.add_argument("--force", action="store_true", help="Overwrite existing materialized files")
212237
ap.add_argument("--format", choices=["json", "human"], default="human")
213238
args = ap.parse_args()
214239

215240
payload = materialize_pack(
216-
args.repo,
241+
args.repo.resolve() if args.repo is not None else repo_root(),
217242
args.target_root,
218243
include_optional=set(args.include_optional),
219244
include_all_optional=args.all_optional,

src/hyperclaw_max/ops_fabric/contracts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def empty_watchdog() -> dict[str, Any]:
4848
"candidates": 0,
4949
"dispatches": 0,
5050
"deliverableActivity": 0,
51-
"normalizedPrincipalVisibleTasks": 0,
51+
"normalizedOwnerVisibleTasks": 0,
5252
"resolved": 0,
5353
},
5454
"incidents": {},

tests/test_materialize_pack.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import json
2+
import os
23
import unittest
34
from pathlib import Path
45
from tempfile import TemporaryDirectory
56

6-
from hyperclaw_max.materialize_pack import load_pack_manifest, materialize_pack
7+
from hyperclaw_max.materialize_pack import load_pack_manifest, materialize_pack, repo_root
78
from hyperclaw_max.ops_fabric.cli import validate_state_dir
89

910

@@ -49,6 +50,18 @@ def test_materialize_pack_can_enable_optional_overlay(self) -> None:
4950
self.assertTrue((Path(tmp) / "workspace-finance" / "AGENTS.md").exists())
5051
self.assertFalse((Path(tmp) / "workspace-legal").exists())
5152

53+
def test_repo_root_prefers_cwd_when_module_path_is_external(self) -> None:
54+
with TemporaryDirectory() as tmp:
55+
fake_module = Path(tmp) / ".venv" / "lib" / "python3.12" / "site-packages" / "hyperclaw_max" / "materialize_pack.py"
56+
fake_module.parent.mkdir(parents=True)
57+
fake_module.write_text("# synthetic module path for repo root discovery\n", encoding="utf-8")
58+
old_cwd = Path.cwd()
59+
try:
60+
os.chdir(REPO_ROOT)
61+
self.assertEqual(repo_root(module_path=fake_module), REPO_ROOT)
62+
finally:
63+
os.chdir(old_cwd)
64+
5265

5366
if __name__ == "__main__":
5467
unittest.main()

0 commit comments

Comments
 (0)