@riddledc/riddle-proof 0.5.37 → 0.5.39
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/README.md +12 -8
- package/dist/checkpoint.cjs +230 -0
- package/dist/checkpoint.d.cts +22 -0
- package/dist/checkpoint.d.ts +22 -0
- package/dist/checkpoint.js +15 -0
- package/dist/{chunk-GN7HSZ6G.js → chunk-ORRP7CXT.js} +161 -3
- package/dist/{chunk-MQ2BHHLX.js → chunk-RDTMR7XR.js} +2 -2
- package/dist/chunk-UQPTCP4D.js +185 -0
- package/dist/{chunk-OASB3CYU.js → chunk-Z3BWCHFV.js} +4 -1
- package/dist/{chunk-J2MERROF.js → chunk-Z7QUCDPT.js} +1 -0
- package/dist/engine-harness.cjs +342 -13
- package/dist/engine-harness.d.cts +6 -2
- package/dist/engine-harness.d.ts +6 -2
- package/dist/engine-harness.js +4 -3
- package/dist/index.cjs +356 -17
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +25 -13
- package/dist/openclaw.js +2 -2
- package/dist/proof-run-engine.d.cts +3 -3
- package/dist/proof-run-engine.d.ts +3 -3
- package/dist/result.cjs +1 -0
- package/dist/result.js +1 -1
- package/dist/runner.cjs +3 -0
- package/dist/runner.js +3 -3
- package/dist/state.cjs +3 -0
- package/dist/state.d.cts +7 -1
- package/dist/state.d.ts +7 -1
- package/dist/state.js +2 -2
- package/dist/types.d.cts +63 -2
- package/dist/types.d.ts +63 -2
- package/lib/workspace-core.mjs +32 -1
- package/package.json +7 -2
- package/runtime/lib/setup.py +55 -9
package/runtime/lib/setup.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"""Setup: create worktrees, install deps, validate args, write state.
|
|
2
2
|
|
|
3
|
-
Idempotent — safe to re-run. Creates per-run worktrees under
|
|
4
|
-
|
|
5
|
-
/tmp/.riddle-proof-worktrees/riddle-proof-<run_id>-before
|
|
6
|
-
/tmp/.riddle-proof-worktrees/riddle-proof-<run_id>-after
|
|
3
|
+
Idempotent — safe to re-run. Creates per-run worktrees under disk-backed
|
|
4
|
+
scratch storage by default:
|
|
5
|
+
/var/tmp/riddle-proof/.riddle-proof-worktrees/riddle-proof-<run_id>-before
|
|
6
|
+
/var/tmp/riddle-proof/.riddle-proof-worktrees/riddle-proof-<run_id>-after
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
import json, subprocess as sp, os, sys, shutil, time, tempfile
|
|
@@ -24,6 +24,7 @@ SAFE_RUN_ID = ''.join(ch if ch.isalnum() or ch in ('-', '_') else '-' for ch in
|
|
|
24
24
|
|
|
25
25
|
AFTER_WORKTREE_BRANCH = 'riddle-proof/' + SAFE_RUN_ID + '-after'
|
|
26
26
|
LEGACY_WORKTREE_DIRS = ('/tmp/riddle-proof-before', '/tmp/riddle-proof-after')
|
|
27
|
+
DEFAULT_SCRATCH_ROOT = '/var/tmp/riddle-proof'
|
|
27
28
|
|
|
28
29
|
if branch.startswith('riddle-proof/'):
|
|
29
30
|
raise SystemExit(
|
|
@@ -158,17 +159,26 @@ def compatible_reuse_source(source_dir, target_dirs):
|
|
|
158
159
|
|
|
159
160
|
|
|
160
161
|
def resolve_worktree_root(repo_dir):
|
|
161
|
-
configured = (
|
|
162
|
+
configured = (os.environ.get('RIDDLE_PROOF_WORKTREE_ROOT') or '').strip()
|
|
162
163
|
if configured:
|
|
163
164
|
return os.path.abspath(os.path.expanduser(configured))
|
|
165
|
+
state_worktree_root = (s.get('worktree_root') or '').strip()
|
|
166
|
+
legacy_tmp_root = os.path.abspath(os.path.join(tempfile.gettempdir(), '.riddle-proof-worktrees'))
|
|
167
|
+
if state_worktree_root and os.path.abspath(os.path.expanduser(state_worktree_root)) != legacy_tmp_root:
|
|
168
|
+
return os.path.abspath(os.path.expanduser(state_worktree_root))
|
|
164
169
|
if os.environ.get('RIDDLE_PROOF_USE_WORKSPACE_WORKTREE_ROOT', '').strip().lower() in ('1', 'true', 'yes'):
|
|
165
170
|
repo_parent = os.path.dirname(os.path.abspath(repo_dir))
|
|
166
171
|
return os.path.join(repo_parent, '.riddle-proof-worktrees')
|
|
167
172
|
|
|
168
|
-
# Proof worktrees are
|
|
169
|
-
#
|
|
170
|
-
#
|
|
171
|
-
|
|
173
|
+
# Proof worktrees and dependency caches are large generated data. Keep
|
|
174
|
+
# them on disk-backed scratch storage by default so tmpfs /tmp remains
|
|
175
|
+
# available for small state files and short-lived artifacts.
|
|
176
|
+
scratch_root = (s.get('scratch_root') or os.environ.get('RIDDLE_PROOF_SCRATCH_ROOT') or '').strip()
|
|
177
|
+
if scratch_root:
|
|
178
|
+
return os.path.join(os.path.abspath(os.path.expanduser(scratch_root)), '.riddle-proof-worktrees')
|
|
179
|
+
if os.environ.get('RIDDLE_PROOF_USE_TMP_SCRATCH', '').strip().lower() in ('1', 'true', 'yes'):
|
|
180
|
+
return os.path.join(tempfile.gettempdir(), 'riddle-proof', '.riddle-proof-worktrees')
|
|
181
|
+
return os.path.join(DEFAULT_SCRATCH_ROOT, '.riddle-proof-worktrees')
|
|
172
182
|
|
|
173
183
|
|
|
174
184
|
def env_flag(name, default=False):
|
|
@@ -202,6 +212,33 @@ def disk_free_bytes(path):
|
|
|
202
212
|
return 0
|
|
203
213
|
|
|
204
214
|
|
|
215
|
+
def disk_snapshot(path):
|
|
216
|
+
probe = path
|
|
217
|
+
while probe and not os.path.exists(probe):
|
|
218
|
+
parent = os.path.dirname(probe)
|
|
219
|
+
if parent == probe:
|
|
220
|
+
break
|
|
221
|
+
probe = parent
|
|
222
|
+
try:
|
|
223
|
+
usage = shutil.disk_usage(probe or tempfile.gettempdir())
|
|
224
|
+
except Exception as exc:
|
|
225
|
+
return {
|
|
226
|
+
'path': path,
|
|
227
|
+
'probe_path': probe or tempfile.gettempdir(),
|
|
228
|
+
'error': str(exc)[:200],
|
|
229
|
+
}
|
|
230
|
+
used = usage.total - usage.free
|
|
231
|
+
percent_used = round((used / usage.total) * 100, 1) if usage.total else 0
|
|
232
|
+
return {
|
|
233
|
+
'path': path,
|
|
234
|
+
'probe_path': probe or tempfile.gettempdir(),
|
|
235
|
+
'total_bytes': usage.total,
|
|
236
|
+
'used_bytes': used,
|
|
237
|
+
'free_bytes': usage.free,
|
|
238
|
+
'percent_used': percent_used,
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
|
|
205
242
|
def prune_scratch_worktrees(worktree_root, keep_dirs, repo_dir):
|
|
206
243
|
report = {
|
|
207
244
|
'requested': True,
|
|
@@ -475,16 +512,24 @@ s['branch'] = branch
|
|
|
475
512
|
s['target_branch'] = target_branch
|
|
476
513
|
s['ship_target_branch'] = target_branch
|
|
477
514
|
s['worktree_root'] = WORKTREE_ROOT
|
|
515
|
+
s['scratch_root'] = os.path.dirname(WORKTREE_ROOT)
|
|
516
|
+
try:
|
|
517
|
+
cache_result = workspace_core('dependency-cache-root', {'projectDir': AFTER_DIR}, timeout=30)
|
|
518
|
+
s['dependency_cache_root'] = cache_result.get('cacheRoot') or ''
|
|
519
|
+
except Exception as exc:
|
|
520
|
+
s['dependency_cache_root_error'] = str(exc)[:200]
|
|
478
521
|
capture_hint = apply_capture_hint(s)
|
|
479
522
|
if capture_hint and capture_hint.get('applied_fields'):
|
|
480
523
|
print('Applied last-good capture hint: ' + ', '.join(capture_hint.get('applied_fields') or []))
|
|
481
524
|
save_state(s)
|
|
482
525
|
print('Prepared workspace via ' + setup.get('source', 'workspace_core') + ': ' + repo_dir)
|
|
483
526
|
os.makedirs(WORKTREE_ROOT, exist_ok=True)
|
|
527
|
+
s['scratch_disk_before_cleanup'] = disk_snapshot(WORKTREE_ROOT)
|
|
484
528
|
scratch_cleanup = prune_scratch_worktrees(WORKTREE_ROOT, (BEFORE_DIR, AFTER_DIR), repo_dir)
|
|
485
529
|
if scratch_cleanup.get('removed') or scratch_cleanup.get('errors'):
|
|
486
530
|
print('Scratch cleanup: removed ' + str(len(scratch_cleanup.get('removed') or [])) + ' stale proof worktree(s)')
|
|
487
531
|
s['scratch_cleanup'] = scratch_cleanup
|
|
532
|
+
s['scratch_disk_after_cleanup'] = disk_snapshot(WORKTREE_ROOT)
|
|
488
533
|
save_state(s)
|
|
489
534
|
cleanup_legacy_branch_worktrees(repo_dir, base_branch)
|
|
490
535
|
|
|
@@ -605,6 +650,7 @@ s['dependency_install'] = {
|
|
|
605
650
|
'before': before_dep_status,
|
|
606
651
|
'after': after_dep_status,
|
|
607
652
|
}
|
|
653
|
+
s['scratch_disk_after_setup'] = disk_snapshot(WORKTREE_ROOT)
|
|
608
654
|
if not (s.get('capture_script') or '').strip():
|
|
609
655
|
s['proof_plan_status'] = 'pending_recon'
|
|
610
656
|
save_state(s)
|