T06 · System Persistence
- Location
scripts/mem_compress.py:460- Finding
Heartbeat Installation Creates Persistent Automatic Execution Instructions
- Content
View full analysis
int: """Install heartbeat integration into the workspace HEARTBEAT.md.""" script_path = Path(__file__).resolve() heartbeat_path = workspace / "HEARTBEAT.md" # Build the heartbeat entry with absolute paths entry = f""" ## Memory Compression (auto — claw-compactor) - Run `python3 {script_path} {workspace} benchmark --json` - If savings >5%: auto-run `python3 {script_path} {workspace} full` - If unprocessed session transcripts exist: run observe - Record results to `memory/heartbeat-state.json` """ # Check if already installed if heartbeat_path.exists(): existing = heartbeat_path.read_text(encoding="utf-8") if "claw-compactor" in existing: print("✅ Already installed in HEARTBEAT.md") return 0 # Append to existing with open(heartbeat_path, "a", encoding="utf-8") as f: f.write(entry) else: # Create new HEARTBEAT.md with open(heartbeat_path, "w", encoding="utf-8") as f: f.write("# HEARTBEAT.md\n" + entry) print(f"✅ Installed claw-compactor heartbeat into {heartbeat_path}") print(f" Script: {script_path}") print(f" Workspace: {workspace}") return 0 ``` ### Technical Analysis The `install` command modifies the workspace's persistent `HEARTBEAT.md` instructions. The inserted content directs an Agent to execute the benchmark automatically and to invoke the mutating `full` pipeline when reported savings exceed five percent. This behavior survives the original process and can affect later Agent sessions. It therefore functions as a persistence mechanism rather than merely performing compression during the user-requested invocation. The command is present in the C ...[truncated 1524 chars]- Remediation
View remediation
