prizmkit 1.1.92 → 1.1.93
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.
- package/bundled/VERSION.json +3 -3
- package/bundled/dev-pipeline/.env.example +0 -4
- package/bundled/dev-pipeline/README.md +9 -39
- package/bundled/dev-pipeline/SCHEMA_ANALYSIS.md +0 -4
- package/bundled/dev-pipeline/assets/prizm-dev-team-integration.md +0 -2
- package/bundled/dev-pipeline/launch-bugfix-daemon.sh +0 -1
- package/bundled/dev-pipeline/launch-feature-daemon.sh +2 -3
- package/bundled/dev-pipeline/launch-refactor-daemon.sh +0 -1
- package/bundled/dev-pipeline/run-bugfix.sh +7 -67
- package/bundled/dev-pipeline/run-feature.sh +6 -84
- package/bundled/dev-pipeline/run-recovery.sh +1 -32
- package/bundled/dev-pipeline/run-refactor.sh +6 -68
- package/bundled/dev-pipeline/tests/test-deploy-safety.sh +3 -3
- package/bundled/dev-pipeline-windows/.env.example +0 -4
- package/bundled/dev-pipeline-windows/SCHEMA_ANALYSIS.md +0 -4
- package/bundled/dev-pipeline-windows/assets/prizm-dev-team-integration.md +0 -2
- package/bundled/dev-pipeline-windows/lib/pipeline.ps1 +13 -90
- package/bundled/dev-pipeline-windows/run-recovery.ps1 +4 -19
- package/bundled/skills/_metadata.json +1 -1
- package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +1 -1
- package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +5 -15
- package/bundled/skills/feature-pipeline-launcher/SKILL.md +4 -4
- package/bundled/skills/feature-pipeline-launcher/references/configuration.md +3 -13
- package/bundled/skills/refactor-pipeline-launcher/SKILL.md +3 -3
- package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +4 -14
- package/bundled/skills-windows/bugfix-pipeline-launcher/SKILL.md +1 -1
- package/bundled/skills-windows/bugfix-pipeline-launcher/references/configuration.md +4 -14
- package/bundled/skills-windows/feature-pipeline-launcher/SKILL.md +4 -4
- package/bundled/skills-windows/feature-pipeline-launcher/references/configuration.md +2 -12
- package/bundled/skills-windows/refactor-pipeline-launcher/SKILL.md +3 -3
- package/bundled/skills-windows/refactor-pipeline-launcher/references/configuration.md +4 -14
- package/package.json +1 -1
- package/bundled/dev-pipeline/scripts/cleanup-logs.py +0 -192
- package/bundled/dev-pipeline-windows/scripts/cleanup-logs.py +0 -192
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Clean up pipeline session logs by age and total size.
|
|
3
|
-
|
|
4
|
-
Targets files under any `.../sessions/.../logs/` directory inside a state dir.
|
|
5
|
-
|
|
6
|
-
Policies:
|
|
7
|
-
1) Remove files older than retention window.
|
|
8
|
-
2) If total remaining size still exceeds max threshold, remove oldest files first
|
|
9
|
-
until within threshold.
|
|
10
|
-
|
|
11
|
-
Usage:
|
|
12
|
-
python3 cleanup-logs.py --state-dir .prizmkit/state/features
|
|
13
|
-
python3 cleanup-logs.py --state-dir .prizmkit/state/bugfix --retention-days 30 --max-total-mb 2048
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
import argparse
|
|
17
|
-
import json
|
|
18
|
-
import os
|
|
19
|
-
import time
|
|
20
|
-
|
|
21
|
-
from utils import error_out, setup_logging
|
|
22
|
-
|
|
23
|
-
LOGGER = setup_logging("cleanup-logs")
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def parse_args():
|
|
27
|
-
parser = argparse.ArgumentParser(description="Cleanup pipeline logs by age and total size.")
|
|
28
|
-
parser.add_argument("--state-dir", required=True, help="State directory to scan")
|
|
29
|
-
parser.add_argument(
|
|
30
|
-
"--retention-days",
|
|
31
|
-
type=int,
|
|
32
|
-
default=14,
|
|
33
|
-
help="Delete logs older than this many days (default: 14)",
|
|
34
|
-
)
|
|
35
|
-
parser.add_argument(
|
|
36
|
-
"--max-total-mb",
|
|
37
|
-
type=int,
|
|
38
|
-
default=1024,
|
|
39
|
-
help="Target max total log size in MB after cleanup (default: 1024)",
|
|
40
|
-
)
|
|
41
|
-
parser.add_argument("--dry-run", action="store_true", help="Report actions without deleting")
|
|
42
|
-
return parser.parse_args()
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def iter_log_files(state_dir):
|
|
46
|
-
"""Yield absolute paths of files inside .../sessions/.../logs/ directories."""
|
|
47
|
-
for root, _dirs, files in os.walk(state_dir):
|
|
48
|
-
if os.path.basename(root) != "logs":
|
|
49
|
-
continue
|
|
50
|
-
|
|
51
|
-
normalized = root.replace("\\", "/")
|
|
52
|
-
if "/sessions/" not in normalized:
|
|
53
|
-
continue
|
|
54
|
-
|
|
55
|
-
for name in files:
|
|
56
|
-
if name == ".DS_Store":
|
|
57
|
-
continue
|
|
58
|
-
yield os.path.join(root, name)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def file_info(path):
|
|
62
|
-
"""Return file metadata dict with path, size, and mtime."""
|
|
63
|
-
st = os.stat(path)
|
|
64
|
-
return {"path": path, "size": st.st_size, "mtime": st.st_mtime}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def remove_file(path, dry_run=False):
|
|
68
|
-
if dry_run:
|
|
69
|
-
return True
|
|
70
|
-
try:
|
|
71
|
-
os.remove(path)
|
|
72
|
-
return True
|
|
73
|
-
except OSError:
|
|
74
|
-
return False
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def cleanup_empty_dirs(state_dir, dry_run=False):
|
|
78
|
-
"""Remove empty logs directories bottom-up."""
|
|
79
|
-
removed = 0
|
|
80
|
-
for root, dirs, _files in os.walk(state_dir, topdown=False):
|
|
81
|
-
for d in dirs:
|
|
82
|
-
full = os.path.join(root, d)
|
|
83
|
-
if os.path.basename(full) != "logs":
|
|
84
|
-
continue
|
|
85
|
-
try:
|
|
86
|
-
if not os.listdir(full):
|
|
87
|
-
if not dry_run:
|
|
88
|
-
os.rmdir(full)
|
|
89
|
-
removed += 1
|
|
90
|
-
except OSError:
|
|
91
|
-
continue
|
|
92
|
-
return removed
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def main():
|
|
96
|
-
args = parse_args()
|
|
97
|
-
state_dir = os.path.abspath(args.state_dir)
|
|
98
|
-
|
|
99
|
-
if not os.path.isdir(state_dir):
|
|
100
|
-
error_out("State directory not found: {}".format(state_dir), code=2)
|
|
101
|
-
|
|
102
|
-
if args.retention_days < 0:
|
|
103
|
-
error_out("retention-days must be >= 0", code=2)
|
|
104
|
-
if args.max_total_mb < 0:
|
|
105
|
-
error_out("max-total-mb must be >= 0", code=2)
|
|
106
|
-
|
|
107
|
-
now = time.time()
|
|
108
|
-
retention_cutoff = now - (args.retention_days * 86400)
|
|
109
|
-
max_total_bytes = args.max_total_mb * 1024 * 1024
|
|
110
|
-
|
|
111
|
-
files = []
|
|
112
|
-
for path in iter_log_files(state_dir):
|
|
113
|
-
try:
|
|
114
|
-
files.append(file_info(path))
|
|
115
|
-
except OSError:
|
|
116
|
-
continue
|
|
117
|
-
|
|
118
|
-
initial_total = sum(f["size"] for f in files)
|
|
119
|
-
|
|
120
|
-
deleted_files = []
|
|
121
|
-
kept_files = []
|
|
122
|
-
|
|
123
|
-
# Step 1: age-based cleanup
|
|
124
|
-
for f in files:
|
|
125
|
-
if f["mtime"] < retention_cutoff:
|
|
126
|
-
if remove_file(f["path"], dry_run=args.dry_run):
|
|
127
|
-
deleted_files.append({**f, "reason": "retention"})
|
|
128
|
-
else:
|
|
129
|
-
kept_files.append(f)
|
|
130
|
-
else:
|
|
131
|
-
kept_files.append(f)
|
|
132
|
-
|
|
133
|
-
# Step 2: size-based cleanup (oldest first)
|
|
134
|
-
current_total = sum(f["size"] for f in kept_files)
|
|
135
|
-
if current_total > max_total_bytes:
|
|
136
|
-
kept_files.sort(key=lambda x: x["mtime"]) # oldest first
|
|
137
|
-
still_kept = []
|
|
138
|
-
for f in kept_files:
|
|
139
|
-
if current_total <= max_total_bytes:
|
|
140
|
-
still_kept.append(f)
|
|
141
|
-
continue
|
|
142
|
-
|
|
143
|
-
if remove_file(f["path"], dry_run=args.dry_run):
|
|
144
|
-
deleted_files.append({**f, "reason": "size"})
|
|
145
|
-
current_total -= f["size"]
|
|
146
|
-
else:
|
|
147
|
-
still_kept.append(f)
|
|
148
|
-
|
|
149
|
-
kept_files = still_kept
|
|
150
|
-
|
|
151
|
-
removed_empty_log_dirs = cleanup_empty_dirs(state_dir, dry_run=args.dry_run)
|
|
152
|
-
|
|
153
|
-
final_total = sum(f["size"] for f in kept_files)
|
|
154
|
-
reclaimed = initial_total - final_total
|
|
155
|
-
|
|
156
|
-
report = {
|
|
157
|
-
"success": True,
|
|
158
|
-
"state_dir": state_dir,
|
|
159
|
-
"dry_run": args.dry_run,
|
|
160
|
-
"retention_days": args.retention_days,
|
|
161
|
-
"max_total_mb": args.max_total_mb,
|
|
162
|
-
"initial_files": len(files),
|
|
163
|
-
"deleted_files": len(deleted_files),
|
|
164
|
-
"deleted_by_reason": {
|
|
165
|
-
"retention": sum(1 for f in deleted_files if f["reason"] == "retention"),
|
|
166
|
-
"size": sum(1 for f in deleted_files if f["reason"] == "size"),
|
|
167
|
-
},
|
|
168
|
-
"removed_empty_log_dirs": removed_empty_log_dirs,
|
|
169
|
-
"initial_total_bytes": initial_total,
|
|
170
|
-
"final_total_bytes": final_total,
|
|
171
|
-
"reclaimed_bytes": reclaimed,
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
LOGGER.info(
|
|
175
|
-
"cleanup complete: deleted=%s reclaimed=%sKB",
|
|
176
|
-
report["deleted_files"],
|
|
177
|
-
int(report["reclaimed_bytes"] / 1024),
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
print(json.dumps(report, indent=2, ensure_ascii=False))
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if __name__ == "__main__":
|
|
184
|
-
try:
|
|
185
|
-
main()
|
|
186
|
-
except KeyboardInterrupt:
|
|
187
|
-
error_out("cleanup-logs interrupted", code=130)
|
|
188
|
-
except SystemExit:
|
|
189
|
-
raise
|
|
190
|
-
except Exception as exc:
|
|
191
|
-
LOGGER.exception("Unhandled exception in cleanup-logs")
|
|
192
|
-
error_out("cleanup-logs failed: {}".format(str(exc)), code=1)
|