junidude14 commited on
Commit
d08cb8a
·
verified ·
1 Parent(s): 7ca14e6

Archive 4 checkpoints (1-4)

Browse files
paper-releases/pbisc-diffusion/updates/20261007T185408Z-scsemi-cleanup-recovery/diffusion/dataset/server_1/maintenance/207d2460f5aa644b/test_update.py ADDED
@@ -0,0 +1,362 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Offline contract tests for the incremental release gate."""
2
+ from __future__ import annotations
3
+
4
+ import fcntl
5
+ import hashlib
6
+ import json
7
+ from pathlib import Path
8
+ import sys
9
+ import tempfile
10
+ from types import SimpleNamespace
11
+ import unittest
12
+ from unittest.mock import patch
13
+
14
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
15
+ import update
16
+
17
+
18
+ class UpdateTests(unittest.TestCase):
19
+ def setUp(self):
20
+ self.temporary = tempfile.TemporaryDirectory(dir='/home/sj_server_1')
21
+ self.addCleanup(self.temporary.cleanup)
22
+ self.root = Path(self.temporary.name) / 'release'
23
+ self.root.mkdir()
24
+ self.maintenance = self.root / 'maintenance'
25
+ self.maintenance.mkdir()
26
+ self.model = Path(self.temporary.name) / 'model8'
27
+ self.paper = Path(self.temporary.name) / 'paper'
28
+ self.other = Path(self.temporary.name) / 'other-paper'
29
+ for path in (self.model, self.paper, self.other):
30
+ path.mkdir()
31
+ (self.maintenance / 'SCOPE.json').write_text(json.dumps({
32
+ 'project_id': 'pbisc-diffusion',
33
+ 'core_roots': {'model8': str(self.model), 'manuscript': str(self.paper)},
34
+ 'maintenance_root': str(self.maintenance),
35
+ 'external_dependencies': [],
36
+ 'forbidden_components': ['.git', '.venv', 'venv', 'runtime_env', '__pycache__',
37
+ 'node_modules', 'Rlib', '.cache'],
38
+ }))
39
+ self.source = self.model / 'weights.pt'
40
+ self.source.write_bytes(b'first')
41
+ self.identifier = '20260928T120000Z-a'
42
+ self.request = {'project_id': 'pbisc-diffusion', 'summary': 'new experiment',
43
+ 'assets': [{'host': 'server_1', 'source': str(self.source),
44
+ 'kind': 'checkpoint', 'state': 'completed'}],
45
+ 'inference_locations': []}
46
+ self.patch_roots = patch.object(update, 'CORE_ROOTS',
47
+ {'model8': self.model, 'manuscript': self.paper})
48
+ self.patch_roots.start()
49
+ self.addCleanup(self.patch_roots.stop)
50
+
51
+ def prepare(self, request=None, identifier=None):
52
+ return update.prepare(self.root, request or self.request, identifier or self.identifier)
53
+
54
+ def test_rejects_other_paper_and_symlink_escape(self):
55
+ bad = json.loads(json.dumps(self.request))
56
+ bad['assets'][0]['source'] = str(self.other / 'weights.bin')
57
+ (self.other / 'weights.bin').write_bytes(b'bad')
58
+ with self.assertRaises(update.UpdateError):
59
+ self.prepare(bad)
60
+ bad['project_id'] = 'another-paper'
61
+ with self.assertRaisesRegex(update.UpdateError, 'wrong_request_project'):
62
+ self.prepare(bad)
63
+ link = self.model / 'escape.bin'
64
+ link.symlink_to(self.other / 'weights.bin')
65
+ bad['assets'][0]['source'] = str(link)
66
+ with self.assertRaises(update.UpdateError):
67
+ self.prepare(bad)
68
+ self.assertFalse((self.root / 'LATEST.json').exists())
69
+
70
+ def test_hash_change_is_incremental_and_old_paths_untouched(self):
71
+ baseline = {'assets': [{'host': 'server_1', 'source': str(self.source),
72
+ 'sha256': hashlib.sha256(b'first').hexdigest()}]}
73
+ (self.root / 'COMBINED_ASSET_INDEX.json').write_text(json.dumps(baseline))
74
+ frozen = self.root / 'RELEASE_LOCK.json'
75
+ frozen.write_bytes(b'{"immutable":true}\n')
76
+ with self.assertRaisesRegex(update.UpdateError, 'no_changed_assets'):
77
+ self.prepare()
78
+ self.source.write_bytes(b'second')
79
+ output = self.prepare()
80
+ rows = json.loads((output / 'manifest.json').read_text())['assets']
81
+ payload = [r for r in rows if r['source'] == str(self.source)][0]
82
+ self.assertEqual(payload['repo_type'], 'model')
83
+ self.assertTrue(payload['bundle_path'].startswith('updates/' + self.identifier + '/'))
84
+ self.assertEqual(baseline, json.loads((self.root / 'COMBINED_ASSET_INDEX.json').read_text()))
85
+ self.assertEqual(frozen.read_bytes(), b'{"immutable":true}\n')
86
+ self.assertFalse((self.root / 'LATEST.json').exists())
87
+
88
+ def test_rejects_running_payload_and_external_checkpoint(self):
89
+ bad = json.loads(json.dumps(self.request))
90
+ bad['assets'][0]['state'] = 'running'
91
+ with self.assertRaises(update.UpdateError):
92
+ self.prepare(bad)
93
+ external = self.other / 'checkpoint.pt'
94
+ external.write_bytes(b'checkpoint')
95
+ scope = json.loads((self.maintenance / 'SCOPE.json').read_text())
96
+ scope['external_dependencies'] = [{'host': 'server_1', 'source': str(external),
97
+ 'reason': 'evaluation'}]
98
+ (self.maintenance / 'SCOPE.json').write_text(json.dumps(scope))
99
+ bad['assets'][0].update(source=str(external), state='completed')
100
+ with self.assertRaises(update.UpdateError):
101
+ self.prepare(bad)
102
+
103
+ def test_parent_conflict_and_lock_refuse_before_publisher(self):
104
+ output = self.prepare()
105
+ (self.root / 'LATEST.json').write_text(json.dumps({'id': 'different'}))
106
+ called = []
107
+ with self.assertRaisesRegex(update.UpdateError, 'parent_changed'):
108
+ update.publish(self.root, self.identifier, execute=True,
109
+ publisher=lambda *_: called.append(1))
110
+ self.assertEqual(called, [])
111
+ (self.root / 'LATEST.json').unlink()
112
+ lock = self.maintenance / '.writer.lock'
113
+ with lock.open('a') as stream:
114
+ fcntl.flock(stream, fcntl.LOCK_EX | fcntl.LOCK_NB)
115
+ with self.assertRaisesRegex(update.UpdateError, 'writer_busy'):
116
+ update.publish(self.root, self.identifier, execute=True,
117
+ publisher=lambda *_: called.append(1))
118
+ self.assertEqual(called, [])
119
+ self.assertTrue(output.exists())
120
+
121
+ def test_latest_never_advances_on_publisher_failure(self):
122
+ self.prepare()
123
+ with self.assertRaisesRegex(update.UpdateError, 'publisher_failed'):
124
+ update.publish(self.root, self.identifier, execute=True,
125
+ publisher=lambda *_: 1)
126
+ self.assertFalse((self.root / 'LATEST.json').exists())
127
+ self.assertFalse((self.maintenance / 'updates' / self.identifier / 'UPDATE_VERIFIED.json').exists())
128
+
129
+ def test_resumes_after_pointer_was_already_committed(self):
130
+ folder = self.prepare()
131
+ manifest_bytes = (folder / 'manifest.json').read_bytes()
132
+ manifest = json.loads(manifest_bytes)
133
+ verified_rows = [dict(row, archive_stat={}, hf_revision='a' * 40)
134
+ for row in manifest['assets']]
135
+ receipt = json.dumps({'status': 'PASS', 'project_id': 'pbisc-diffusion',
136
+ 'update_id': self.identifier,
137
+ 'parent_latest': None,
138
+ 'manifest_sha256': hashlib.sha256(manifest_bytes).hexdigest(),
139
+ 'assets': verified_rows})
140
+ (folder / 'UPDATE_VERIFIED.json').write_text(receipt)
141
+ pointer = {'id': self.identifier, 'project_id': 'pbisc-diffusion',
142
+ 'verified_receipt_sha256': hashlib.sha256(receipt.encode()).hexdigest()}
143
+ (self.root / 'LATEST.json').write_text(json.dumps(pointer))
144
+ with patch.object(update, '_refresh_catalog') as refresh, \
145
+ patch.object(update, '_remote_latest', return_value=pointer), \
146
+ patch.object(update, '_hf_latest', return_value=pointer), \
147
+ patch.object(update, '_hf_api', return_value=object()), \
148
+ patch.object(update, '_verify_rows', return_value=verified_rows), \
149
+ patch.object(update, '_check_publisher_receipts'):
150
+ result = update.publish(self.root, self.identifier, execute=True,
151
+ publisher=lambda *_: self.fail('publisher reran'))
152
+ self.assertEqual(result, pointer)
153
+ refresh.assert_called_once_with(self.root)
154
+ self.assertEqual(json.loads((folder / 'STATUS.json').read_text())['phase'], 'verified')
155
+
156
+ def test_verified_replay_uses_frozen_assets_after_source_changes(self):
157
+ folder = self.prepare()
158
+ manifest = json.loads((folder / 'manifest.json').read_text())
159
+ scope = update._scope(self.root)
160
+ self.source.write_bytes(b'changed after publication')
161
+ with self.assertRaisesRegex(update.UpdateError, 'manifest_row_scope_mismatch'):
162
+ update._validate_manifest_rows(self.root, folder, manifest, scope, False)
163
+ update._validate_manifest_rows(self.root, folder, manifest, scope, False, True)
164
+ row = manifest['assets'][0]
165
+ paper = update._publisher()
166
+
167
+ class API:
168
+ def repo_info(self, **_):
169
+ return SimpleNamespace(sha='a' * 40)
170
+
171
+ info = {'size': row['bytes'], 'lfs': {'sha256': row['sha256']}}
172
+ with patch.object(update, '_hf_api', return_value=API()), \
173
+ patch.object(paper, 'check_visibility'), \
174
+ patch.object(paper, 'source_digest', return_value='0' * 64) as source_digest, \
175
+ patch.object(paper, 'remote_call', return_value={'event': 'verified_existing', 'stat': {}}), \
176
+ patch.object(paper.base, 'remote_file', return_value=info):
177
+ with self.assertRaisesRegex(update.UpdateError, 'source_changed'):
178
+ update._verify_rows(self.root, self.identifier, [row])
179
+ source_digest.reset_mock()
180
+ verified = update._verify_rows(self.root, self.identifier, [row], True)
181
+ source_digest.assert_not_called()
182
+ self.assertEqual(verified[0]['sha256'], row['sha256'])
183
+
184
+ def test_completed_pointer_replay_survives_source_change(self):
185
+ folder = self.prepare()
186
+ manifest_bytes = (folder / 'manifest.json').read_bytes()
187
+ manifest = json.loads(manifest_bytes)
188
+ rows = [dict(row, archive_stat={}, hf_revision='a' * 40)
189
+ for row in manifest['assets']]
190
+ receipt = {'status': 'PASS', 'project_id': 'pbisc-diffusion',
191
+ 'update_id': self.identifier, 'parent_latest': None,
192
+ 'manifest_sha256': hashlib.sha256(manifest_bytes).hexdigest(),
193
+ 'assets': rows}
194
+ verified_path = folder / 'UPDATE_VERIFIED.json'
195
+ verified_path.write_text(json.dumps(receipt))
196
+ pointer = {'id': self.identifier, 'project_id': 'pbisc-diffusion',
197
+ 'receipt_revision': 'a' * 40,
198
+ 'verified_receipt_sha256': hashlib.sha256(verified_path.read_bytes()).hexdigest()}
199
+ (folder / 'LATEST.json').write_text(json.dumps(pointer))
200
+ (self.root / 'LATEST.json').write_text(json.dumps(pointer))
201
+ self.source.write_bytes(b'changed after publication')
202
+ with patch.object(update, '_remote_latest', return_value=pointer), \
203
+ patch.object(update, '_hf_latest', return_value=pointer), \
204
+ patch.object(update, '_hf_api', return_value=object()), \
205
+ patch.object(update, '_verify_rows', return_value=rows), \
206
+ patch.object(update, '_check_publisher_receipts'), \
207
+ patch.object(update, '_refresh_catalog'), \
208
+ patch('huggingface_hub.hf_hub_download', return_value=str(verified_path)):
209
+ result = update.publish(self.root, self.identifier, execute=True,
210
+ publisher=lambda *_: self.fail('publisher reran'))
211
+ self.assertEqual(result, pointer)
212
+
213
+ def test_wrong_pinned_hf_digest_cannot_verify(self):
214
+ folder = self.prepare()
215
+ row = json.loads((folder / 'manifest.json').read_text())['assets'][0]
216
+ paper = update._publisher()
217
+
218
+ class API:
219
+ def repo_info(self, **_):
220
+ return SimpleNamespace(sha='a' * 40)
221
+
222
+ info = {'path': row['remote_path'], 'size': row['bytes'],
223
+ 'lfs': {'sha256': '0' * 64}}
224
+ with patch.object(update, '_hf_api', return_value=API()), \
225
+ patch.object(paper, 'check_visibility'), \
226
+ patch.object(paper, 'remote_call', return_value={'event': 'verified_existing', 'stat': {}}), \
227
+ patch.object(paper.base, 'remote_file', return_value=info):
228
+ with self.assertRaisesRegex(update.UpdateError, 'hf_payload_digest_mismatch'):
229
+ update._verify_rows(self.root, self.identifier, [row])
230
+
231
+ def test_remote_model8_path_and_host_namespace(self):
232
+ request = json.loads(json.dumps(self.request))
233
+ request['assets'][0]['host'] = 'server_2'
234
+ paper = update._publisher()
235
+ with patch.object(update, '_remote_stat', return_value={
236
+ 'dev': 1, 'ino': 2, 'size': 5, 'mtime_ns': 3,
237
+ }), patch.object(paper, 'source_digest', return_value='a' * 64):
238
+ folder = self.prepare(request)
239
+ row = json.loads((folder / 'manifest.json').read_text())['assets'][0]
240
+ self.assertEqual(row['host'], 'server_2')
241
+ self.assertIn('/server_2/model8/', row['bundle_path'])
242
+ self.assertEqual(row['repo_type'], 'model')
243
+
244
+ def test_maintenance_requires_explicit_kind_and_checkpoint_extension(self):
245
+ policy = self.maintenance / 'POLICY.md'
246
+ policy.write_text('policy\n')
247
+ request = json.loads(json.dumps(self.request))
248
+ request['assets'][0].update(source=str(policy), kind='code')
249
+ with self.assertRaisesRegex(update.UpdateError, 'maintenance_kind_scope'):
250
+ self.prepare(request)
251
+ request['assets'][0]['kind'] = 'maintenance'
252
+ folder = self.prepare(request)
253
+ row = json.loads((folder / 'manifest.json').read_text())['assets'][0]
254
+ self.assertEqual(row['repo_type'], 'dataset')
255
+ self.assertIn('/maintenance/', row['bundle_path'])
256
+ other = json.loads(json.dumps(self.request))
257
+ other['assets'][0]['source'] = str(self.model / 'condition.npz')
258
+ (self.model / 'condition.npz').write_bytes(b'npz')
259
+ with self.assertRaisesRegex(update.UpdateError, 'checkpoint_extension_refused'):
260
+ self.prepare(other, '20260928T120001Z-b')
261
+
262
+ def test_locator_requires_evidence_for_completion_and_refuses_symlinks(self):
263
+ output = self.model / 'prediction.txt'
264
+ request = {'project_id': 'pbisc-diffusion', 'summary': 'inference pointer',
265
+ 'assets': [], 'inference_locations': [{
266
+ 'host': 'server_1', 'path': str(output), 'state': 'completed',
267
+ }]}
268
+ with self.assertRaisesRegex(update.UpdateError, 'completed_locator_evidence_missing'):
269
+ self.prepare(request)
270
+ receipt = self.model / 'receipt.json'
271
+ output.write_text('prediction')
272
+ receipt.write_text('{}')
273
+ request['inference_locations'][0]['receipt'] = str(receipt)
274
+ folder = self.prepare(request)
275
+ location = json.loads((folder / 'inference_locations.json').read_text())['locations'][0]
276
+ self.assertEqual(location['sha_basis'], 'existing_receipt')
277
+ self.assertEqual(location['observed_output']['kind'], 'file')
278
+ link = self.model / 'linked.txt'
279
+ link.symlink_to(output)
280
+ request['inference_locations'][0].update(path=str(link), state='running')
281
+ with self.assertRaisesRegex(update.UpdateError, 'locator_symlink_refused'):
282
+ self.prepare(request, '20260928T120001Z-b')
283
+
284
+ def test_planned_locator_can_be_missing_with_explicit_presence(self):
285
+ request = {'project_id': 'pbisc-diffusion', 'summary': 'planned inference',
286
+ 'assets': [], 'inference_locations': [{
287
+ 'host': 'server_1', 'path': str(self.model / 'future.txt'),
288
+ 'state': 'planned',
289
+ }]}
290
+ folder = self.prepare(request)
291
+ location = json.loads((folder / 'inference_locations.json').read_text())['locations'][0]
292
+ self.assertEqual(location['sha_basis'], 'presence_unverified')
293
+ self.assertEqual(location['observed_output']['presence'], 'missing_unverified')
294
+
295
+ def test_hf_record_conflict_and_latest_parent_cas(self):
296
+ record = self.root / 'record.json'
297
+ record.write_text('{"id":"ours"}\n')
298
+ old = self.root / 'old.json'
299
+ old.write_text('{"id":"theirs"}\n')
300
+
301
+ class API:
302
+ def repo_info(self, **_):
303
+ return SimpleNamespace(sha='a' * 40)
304
+
305
+ def create_commit(self, **_):
306
+ raise AssertionError('commit must not run')
307
+
308
+ paper = update._publisher()
309
+ with patch.object(paper.base, 'remote_file', return_value={'path': 'exists'}), \
310
+ patch('huggingface_hub.hf_hub_download', return_value=str(old)):
311
+ with self.assertRaisesRegex(update.UpdateError, 'immutable_hf_record_conflict'):
312
+ update._hf_upload_verified(API(), record, 'remote/immutable.json')
313
+ with self.assertRaisesRegex(update.UpdateError, 'hf_latest_parent_changed'):
314
+ update._hf_upload_verified(API(), record, 'remote/LATEST.json',
315
+ mutable=True, expected_parent=None)
316
+
317
+ def test_edited_prepared_manifest_cannot_change_asset_classification(self):
318
+ folder = self.prepare()
319
+ path = folder / 'manifest.json'
320
+ manifest = json.loads(path.read_text())
321
+ manifest['assets'][0]['repo_type'] = 'dataset'
322
+ manifest['assets'][0]['repo_id'] = 'junidude14/PBISC-data'
323
+ path.write_text(json.dumps(manifest))
324
+ with self.assertRaisesRegex(update.UpdateError, 'manifest_row_scope_mismatch'):
325
+ update.publish(self.root, self.identifier, execute=True,
326
+ publisher=lambda *_: self.fail('publisher must not run'))
327
+ self.assertFalse((self.root / 'LATEST.json').exists())
328
+
329
+ def test_history_uses_only_reachable_verified_receipt(self):
330
+ folder = self.prepare()
331
+ manifest = json.loads((folder / 'manifest.json').read_text())
332
+ receipt = {'status': 'PASS', 'project_id': 'pbisc-diffusion',
333
+ 'update_id': self.identifier, 'parent_latest': None,
334
+ 'assets': manifest['assets']}
335
+ receipt_path = folder / 'UPDATE_VERIFIED.json'
336
+ receipt_path.write_text(json.dumps(receipt))
337
+ orphan = self.maintenance / 'updates' / '20260928T120002Z-orphan'
338
+ orphan.mkdir()
339
+ (orphan / 'UPDATE_VERIFIED.json').write_text(json.dumps({
340
+ 'status': 'PASS', 'assets': [{'host': 'server_1', 'source': str(self.source),
341
+ 'sha256': '0' * 64}],
342
+ }))
343
+ pointer = {'id': self.identifier,
344
+ 'verified_receipt_sha256': hashlib.sha256(receipt_path.read_bytes()).hexdigest(),
345
+ 'receipt_revision': 'a' * 40,
346
+ 'parent': None}
347
+ (self.root / 'LATEST.json').write_text(json.dumps(pointer))
348
+ with self.assertRaisesRegex(update.UpdateError, 'no_changed_assets'):
349
+ self.prepare(identifier='20260928T120003Z-next')
350
+ self.source.write_bytes(b'new content')
351
+ next_folder = self.prepare(identifier='20260928T120003Z-next')
352
+ next_manifest = json.loads((next_folder / 'manifest.json').read_text())
353
+ self.assertEqual(next_manifest['parent_latest'], pointer)
354
+ self.assertEqual(update._parent_ref(pointer), {
355
+ 'id': self.identifier,
356
+ 'verified_receipt_sha256': pointer['verified_receipt_sha256'],
357
+ 'receipt_revision': 'a' * 40,
358
+ })
359
+
360
+
361
+ if __name__ == '__main__':
362
+ unittest.main()
paper-releases/pbisc-diffusion/updates/20261007T185408Z-scsemi-cleanup-recovery/diffusion/dataset/server_1/maintenance/38e4c628399ccf84/update.py ADDED
@@ -0,0 +1,799 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Scoped, CPU-only incremental PBISC-diffusion publication.
3
+
4
+ Prepare is local (server_2 source metadata requires SSH). Publish is explicit and
5
+ uses the frozen paper publisher in a fresh process. No GPU work is started.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import argparse
10
+ import fcntl
11
+ import hashlib
12
+ import json
13
+ import os
14
+ from pathlib import Path, PurePosixPath
15
+ import re
16
+ import shlex
17
+ import stat
18
+ import subprocess
19
+ import sys
20
+ import tempfile
21
+ from typing import Any, Callable
22
+
23
+ ROOT = Path(__file__).resolve().parent.parent
24
+ CORE_ROOTS = {
25
+ 'model8': Path('/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion'),
26
+ 'manuscript': Path('/home/sj_server_1/PBISC/paper-release-20260928/manuscript'),
27
+ }
28
+ REMOTE = 'spark-0110'
29
+ REMOTE_ROOT = '/home/sj_server_2/PBISC/paper-release-20260928'
30
+ PREFIX = 'paper-releases/pbisc-diffusion'
31
+ ID_RE = re.compile(r'[0-9]{8}T[0-9]{6}Z-[a-z0-9-]+\Z')
32
+ SHA_RE = re.compile(r'[0-9a-f]{64}\Z')
33
+ STATES = {'completed', 'final', 'intermediate', 'stopped'}
34
+ LOCATOR_STATES = STATES | {'running', 'planned', 'failed', 'presence_only'}
35
+ FORBIDDEN = {'.git', '.venv', 'venv', 'runtime_env', '__pycache__', 'node_modules', 'Rlib', '.cache'}
36
+ NON_PAYLOAD_KINDS = {'output', 'outputs', 'generated', 'inference', 'sample', 'samples', 'prediction', 'predictions'}
37
+ ALLOWED_KINDS = {'checkpoint', 'condition', 'code', 'manuscript', 'data', 'metadata',
38
+ 'report', 'figure', 'table', 'log', 'provenance', 'maintenance',
39
+ 'policy', 'config', 'test', 'document'}
40
+ MAINTENANCE_FILES = {'POLICY.md', 'SCOPE.json', 'update.py', 'test_update.py',
41
+ 'catalog.py', 'test_catalog.py', 'CURRENT.md', 'request.example.json'}
42
+
43
+
44
+ class UpdateError(Exception):
45
+ pass
46
+
47
+
48
+ def _json(path: Path) -> Any:
49
+ return json.loads(path.read_text(encoding='utf-8'))
50
+
51
+
52
+ def _bytes(value: Any) -> bytes:
53
+ return (json.dumps(value, sort_keys=True, indent=2, ensure_ascii=False) + '\n').encode()
54
+
55
+
56
+ def _atomic(path: Path, data: bytes) -> None:
57
+ if path.is_symlink() or path.parent.is_symlink():
58
+ raise UpdateError('unsafe_output_path')
59
+ path.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
60
+ with tempfile.NamedTemporaryFile(dir=path.parent, prefix='.owned-', delete=False) as stream:
61
+ temporary = Path(stream.name)
62
+ stream.write(data)
63
+ stream.flush()
64
+ os.fsync(stream.fileno())
65
+ try:
66
+ os.replace(temporary, path)
67
+ finally:
68
+ temporary.unlink(missing_ok=True)
69
+
70
+
71
+ def _path(value: Any, host: str) -> Path:
72
+ if not isinstance(value, str) or not value.startswith('/') or '\\' in value or any(ord(c) < 32 for c in value):
73
+ raise UpdateError('invalid_source_path')
74
+ path = PurePosixPath(value)
75
+ if str(path) != value or any(part in ('.', '..') for part in path.parts):
76
+ raise UpdateError('invalid_source_path')
77
+ allowed_homes = ('/home/sj_server_1/',) if host == 'server_1' else ('/home/sj_server_1/', '/home/sj_server_2/')
78
+ if not value.startswith(allowed_homes):
79
+ raise UpdateError('wrong_source_host')
80
+ return Path(value)
81
+
82
+
83
+ def _safe_local(path: Path) -> None:
84
+ current = Path('/')
85
+ for part in path.parts[1:]:
86
+ current /= part
87
+ if current.is_symlink():
88
+ raise UpdateError('source_symlink_refused')
89
+ st = path.lstat()
90
+ if not stat.S_ISREG(st.st_mode):
91
+ raise UpdateError('source_not_regular')
92
+
93
+
94
+ def _scope(root: Path) -> dict[str, Any]:
95
+ maintenance = root / 'maintenance'
96
+ if maintenance.is_symlink() or maintenance.resolve() != maintenance:
97
+ raise UpdateError('unsafe_maintenance_root')
98
+ if (maintenance / 'SCOPE.json').is_symlink():
99
+ raise UpdateError('unsafe_scope_file')
100
+ scope = _json(maintenance / 'SCOPE.json')
101
+ if not isinstance(scope, dict) or scope.get('project_id') != 'pbisc-diffusion':
102
+ raise UpdateError('wrong_project_scope')
103
+ if scope.get('core_roots') != {k: str(v) for k, v in CORE_ROOTS.items()}:
104
+ raise UpdateError('wrong_core_roots')
105
+ if scope.get('maintenance_root') != str(maintenance):
106
+ raise UpdateError('wrong_maintenance_root')
107
+ forbidden = scope.get('forbidden_components')
108
+ if not isinstance(forbidden, list) or not FORBIDDEN.issubset(set(forbidden)):
109
+ raise UpdateError('missing_forbidden_components')
110
+ dependencies = scope.get('external_dependencies')
111
+ if not isinstance(dependencies, list):
112
+ raise UpdateError('invalid_dependencies')
113
+ for item in dependencies:
114
+ if (not isinstance(item, dict) or item.get('host') not in ('server_1', 'server_2')
115
+ or not isinstance(item.get('reason'), str) or not item['reason'].strip()):
116
+ raise UpdateError('invalid_dependency')
117
+ _path(item.get('source'), item['host'])
118
+ return scope
119
+
120
+
121
+ def _allow(path: Path, host: str, scope: dict[str, Any], *, internal: Path | None = None) -> str:
122
+ if any(part in set(scope['forbidden_components']) for part in path.parts):
123
+ raise UpdateError('forbidden_component')
124
+ if internal is not None and host == 'server_1' and path.is_relative_to(internal):
125
+ return 'internal'
126
+ if host == 'server_1' and path.parent == Path(scope['maintenance_root']) and path.name in MAINTENANCE_FILES:
127
+ return 'maintenance'
128
+ for name, root in CORE_ROOTS.items():
129
+ if path.is_relative_to(root) and path != root:
130
+ return name
131
+ if any(item['host'] == host and item['source'] == str(path)
132
+ for item in scope['external_dependencies']):
133
+ return 'dependency'
134
+ raise UpdateError('source_outside_project_scope')
135
+
136
+
137
+ def _publisher():
138
+ sys.path.insert(0, str(ROOT / 'tools'))
139
+ import publish_paper_assets as paper
140
+ return paper
141
+
142
+
143
+ def _remote_stat(path: Path) -> dict[str, int]:
144
+ code = '''import json,os,stat,sys
145
+ p=sys.argv[1]; q='/'
146
+ for part in p.strip('/').split('/'):
147
+ q=os.path.join(q,part)
148
+ if os.path.islink(q): raise SystemExit(2)
149
+ s=os.lstat(p)
150
+ if not stat.S_ISREG(s.st_mode): raise SystemExit(2)
151
+ print(json.dumps(dict(dev=s.st_dev,ino=s.st_ino,size=s.st_size,mtime_ns=s.st_mtime_ns)))'''
152
+ result = subprocess.run(['ssh', '-o', 'BatchMode=yes', REMOTE,
153
+ shlex.join(['python3', '-B', '-c', code, str(path)])],
154
+ capture_output=True, text=True, check=False)
155
+ if result.returncode:
156
+ raise UpdateError('remote_source_unavailable')
157
+ return json.loads(result.stdout)
158
+
159
+
160
+ def _locator_stat(path: Path, host: str) -> dict[str, Any]:
161
+ """Observe a locator without hashing large generated outputs."""
162
+ if host == 'server_1':
163
+ current = Path('/')
164
+ for part in path.parts[1:]:
165
+ current /= part
166
+ if current.is_symlink():
167
+ raise UpdateError('locator_symlink_refused')
168
+ if not current.exists():
169
+ return {'presence': 'missing_unverified'}
170
+ st = path.lstat()
171
+ return {'presence': 'observed', 'kind': 'file' if stat.S_ISREG(st.st_mode) else 'directory' if stat.S_ISDIR(st.st_mode) else 'other',
172
+ 'stat': {'dev': st.st_dev, 'ino': st.st_ino, 'size': st.st_size, 'mtime_ns': st.st_mtime_ns}}
173
+ code = '''import json,os,stat,sys
174
+ p=sys.argv[1]; q='/'
175
+ for part in p.strip('/').split('/'):
176
+ q=os.path.join(q,part)
177
+ if os.path.islink(q): raise SystemExit(2)
178
+ if not os.path.exists(q):
179
+ print(json.dumps({'presence':'missing_unverified'})); raise SystemExit(0)
180
+ s=os.lstat(p)
181
+ k='file' if stat.S_ISREG(s.st_mode) else 'directory' if stat.S_ISDIR(s.st_mode) else 'other'
182
+ print(json.dumps({'presence':'observed','kind':k,'stat':dict(dev=s.st_dev,ino=s.st_ino,size=s.st_size,mtime_ns=s.st_mtime_ns)}))'''
183
+ result = subprocess.run(['ssh', '-o', 'BatchMode=yes', REMOTE,
184
+ shlex.join(['python3', '-B', '-c', code, str(path)])],
185
+ capture_output=True, text=True, check=False)
186
+ if result.returncode:
187
+ raise UpdateError('remote_locator_unavailable')
188
+ return json.loads(result.stdout)
189
+
190
+
191
+ def _row(host: str, path: Path, kind: str, identifier: str, scope: dict[str, Any]) -> dict[str, Any]:
192
+ area = _allow(path, host, scope)
193
+ if host == 'server_1':
194
+ _safe_local(path)
195
+ snap = _publisher().base.snapshot(path.lstat()) if host == 'server_1' else _remote_stat(path)
196
+ if kind == 'checkpoint' and area != 'model8':
197
+ raise UpdateError('checkpoint_outside_model8')
198
+ if kind == 'checkpoint' and path.suffix.lower() not in {'.pt', '.pth', '.safetensors'}:
199
+ raise UpdateError('checkpoint_extension_refused')
200
+ if kind == 'condition' and path.suffix.lower() != '.npz':
201
+ raise UpdateError('condition_requires_npz')
202
+ if kind not in ALLOWED_KINDS:
203
+ raise UpdateError('generated_payload_refused')
204
+ if (area == 'maintenance') != (kind == 'maintenance'):
205
+ raise UpdateError('maintenance_kind_scope')
206
+ if kind not in {'checkpoint', 'condition'} and any(part.lower() in NON_PAYLOAD_KINDS for part in path.parts):
207
+ raise UpdateError('generated_payload_refused')
208
+ root = CORE_ROOTS.get(area)
209
+ relative = path.relative_to(root) if root is not None else Path(hashlib.sha256(str(path).encode()).hexdigest()[:16]) / path.name
210
+ bundle = PurePosixPath('updates') / identifier / 'diffusion' / ('model' if kind == 'checkpoint' else 'dataset') / host / area / PurePosixPath(*relative.parts)
211
+ repo_type = 'model' if kind == 'checkpoint' else 'dataset'
212
+ repo_id = 'junidude14/PBISC' if repo_type == 'model' else 'junidude14/PBISC-data'
213
+ row = {'host': host, 'source': str(path), 'bundle_path': str(bundle), 'repo_type': repo_type,
214
+ 'repo_id': repo_id, 'remote_path': str(PurePosixPath(PREFIX) / bundle),
215
+ 'bytes': snap['size'], 'expected_stat': snap, 'category': kind}
216
+ row['sha256'] = _publisher().source_digest(row)
217
+ return row
218
+
219
+
220
+ def _history(root: Path) -> dict[tuple[str, str], str]:
221
+ seen = {}
222
+ baseline = root / 'COMBINED_ASSET_INDEX.json'
223
+ if baseline.exists():
224
+ for row in _json(baseline).get('assets', []):
225
+ seen[row['host'], row['source']] = row['sha256']
226
+ pointer = _latest(root)
227
+ chain = []
228
+ visited = set()
229
+ while pointer is not None:
230
+ identifier = pointer.get('id') if isinstance(pointer, dict) else None
231
+ if not isinstance(identifier, str) or not ID_RE.fullmatch(identifier) or identifier in visited:
232
+ raise UpdateError('invalid_latest_chain')
233
+ visited.add(identifier)
234
+ path = root / 'maintenance' / 'updates' / identifier / 'UPDATE_VERIFIED.json'
235
+ if path.is_symlink():
236
+ raise UpdateError('unsafe_verified_receipt')
237
+ verified = _json(path)
238
+ if (verified.get('status') != 'PASS' or verified.get('update_id') != identifier
239
+ or pointer.get('verified_receipt_sha256') != hashlib.sha256(path.read_bytes()).hexdigest()):
240
+ raise UpdateError('invalid_latest_chain')
241
+ chain.append(verified)
242
+ pointer = verified.get('parent_latest')
243
+ for verified in reversed(chain):
244
+ for row in verified.get('assets', []):
245
+ seen[row['host'], row['source']] = row['sha256']
246
+ return seen
247
+
248
+
249
+ def _latest(root: Path) -> dict[str, Any] | None:
250
+ path = root / 'LATEST.json'
251
+ if path.is_symlink():
252
+ raise UpdateError('unsafe_latest_pointer')
253
+ return _json(path) if path.exists() else None
254
+
255
+
256
+ def _metadata_row(path: Path, identifier: str, name: str) -> dict[str, Any]:
257
+ _safe_local(path)
258
+ paper = _publisher()
259
+ snap = paper.base.snapshot(path.lstat())
260
+ with paper.base.open_source(path, snap) as stream:
261
+ digest = paper.base.hash_source(path, stream, snap)
262
+ bundle = str(PurePosixPath('updates') / identifier / 'diffusion' / 'metadata' / name)
263
+ return dict(host='server_1', source=str(path), bundle_path=bundle,
264
+ repo_type='dataset', repo_id='junidude14/PBISC-data',
265
+ remote_path=str(PurePosixPath(PREFIX) / bundle), bytes=snap['size'],
266
+ expected_stat=snap, sha256=digest['sha256'], category='update_metadata')
267
+
268
+
269
+ def prepare(root: Path, request: dict[str, Any], identifier: str) -> Path:
270
+ root = root.absolute()
271
+ if not ID_RE.fullmatch(identifier):
272
+ raise UpdateError('invalid_update_id')
273
+ scope = _scope(root)
274
+ if not isinstance(request, dict) or request.get('project_id') != 'pbisc-diffusion':
275
+ raise UpdateError('wrong_request_project')
276
+ summary = request.get('summary')
277
+ if not isinstance(summary, str) or not summary.strip():
278
+ raise UpdateError('summary_required')
279
+ assets, locations = request.get('assets'), request.get('inference_locations')
280
+ if not isinstance(assets, list) or not isinstance(locations, list):
281
+ raise UpdateError('invalid_request_lists')
282
+ parent = _latest(root)
283
+ rows = []
284
+ observed = _history(root)
285
+ seen_sources = set()
286
+ for item in assets:
287
+ if not isinstance(item, dict) or item.get('host') not in ('server_1', 'server_2'):
288
+ raise UpdateError('invalid_asset')
289
+ if item.get('state') not in STATES:
290
+ raise UpdateError('payload_state_refused')
291
+ host, kind = item['host'], item.get('kind')
292
+ if not isinstance(kind, str):
293
+ raise UpdateError('invalid_kind')
294
+ path = _path(item.get('source'), host)
295
+ if (host, str(path)) in seen_sources:
296
+ raise UpdateError('duplicate_source')
297
+ seen_sources.add((host, str(path)))
298
+ row = _row(host, path, kind, identifier, scope)
299
+ if observed.get((host, str(path))) != row['sha256']:
300
+ row['state'] = item['state']
301
+ rows.append(row)
302
+ checked_locations = []
303
+ for item in locations:
304
+ if not isinstance(item, dict) or item.get('host') not in ('server_1', 'server_2'):
305
+ raise UpdateError('invalid_inference_location')
306
+ if item.get('state') not in LOCATOR_STATES:
307
+ raise UpdateError('invalid_inference_state')
308
+ host = item['host']
309
+ path = _path(item.get('path'), host)
310
+ _allow(path, host, scope)
311
+ receipt = item.get('receipt')
312
+ output_observation = _locator_stat(path, host)
313
+ receipt_observation = None
314
+ if receipt is not None:
315
+ receipt_path = _path(receipt, host)
316
+ _allow(receipt_path, host, scope)
317
+ receipt_observation = _locator_stat(receipt_path, host)
318
+ if item['state'] in {'completed', 'final'}:
319
+ if (output_observation.get('kind') != 'file' or receipt_observation is None
320
+ or receipt_observation.get('kind') != 'file'):
321
+ raise UpdateError('completed_locator_evidence_missing')
322
+ sha = item.get('sha256')
323
+ if sha is not None and (not isinstance(sha, str) or not SHA_RE.fullmatch(sha)):
324
+ raise UpdateError('invalid_locator_sha256')
325
+ basis = 'existing_receipt' if receipt_observation and receipt_observation.get('kind') == 'file' else 'presence_unverified'
326
+ checked_locations.append(dict(item, observed_output=output_observation,
327
+ observed_receipt=receipt_observation,
328
+ sha_basis=basis, sha256_basis=basis))
329
+ if not rows and not checked_locations:
330
+ raise UpdateError('no_changed_assets')
331
+ updates_root = root / 'maintenance' / 'updates'
332
+ if updates_root.is_symlink():
333
+ raise UpdateError('unsafe_updates_root')
334
+ folder = updates_root / identifier
335
+ if folder.exists():
336
+ raise UpdateError('update_id_exists')
337
+ folder.mkdir(mode=0o700, parents=True)
338
+ _atomic(folder / 'request.json', _bytes(request))
339
+ _atomic(folder / 'inference_locations.json', _bytes({'project_id': 'pbisc-diffusion',
340
+ 'update_id': identifier, 'locations': checked_locations}))
341
+ note = f'# PBISC-diffusion update {identifier}\n\n{summary.strip()}\n\nPayload states are recorded as supplied. Inference locations are pointers, not archived generated outputs.\n'
342
+ _atomic(folder / 'NOTE.md', note.encode())
343
+ rows.extend([_metadata_row(folder / 'request.json', identifier, 'request.json'),
344
+ _metadata_row(folder / 'inference_locations.json', identifier, 'inference_locations.json'),
345
+ _metadata_row(folder / 'NOTE.md', identifier, 'NOTE.md')])
346
+ if len({r['bundle_path'] for r in rows}) != len(rows):
347
+ raise UpdateError('duplicate_bundle_path')
348
+ manifest = {'schema': 'pbisc.diffusion.update-manifest.v1', 'project_id': 'pbisc-diffusion',
349
+ 'update_id': identifier, 'parent_latest': parent, 'assets': rows}
350
+ _atomic(folder / 'manifest.json', _bytes(manifest))
351
+ _atomic(folder / 'STATUS.json', _bytes({'phase': 'prepared', 'update_id': identifier}))
352
+ return folder
353
+
354
+
355
+ def _run_publisher(root: Path, identifier: str, manifest: Path, work: Path) -> int:
356
+ code = ("import sys; from pathlib import Path; "
357
+ "sys.path.insert(0,str(Path(sys.argv[1]))); import publish_paper_assets as p; "
358
+ "p.PREFIX=sys.argv[2]; sys.exit(p.main([sys.argv[3],'--phase','all',"
359
+ "'--work-dir',sys.argv[4],'--execute']))")
360
+ prefix = str(PurePosixPath(PREFIX) / 'updates' / identifier)
361
+ result = subprocess.run([sys.executable, '-B', '-c', code, str(root / 'tools'), prefix,
362
+ str(manifest), str(work)], check=False)
363
+ return result.returncode
364
+
365
+
366
+ def _remote_latest(value: dict[str, Any] | None = None,
367
+ expected: dict[str, Any] | None = None) -> dict[str, Any] | None:
368
+ code = '''import fcntl,json,os,sys,tempfile
369
+ from pathlib import Path
370
+ p=Path('/home/sj_server_2/PBISC/paper-release-20260928/LATEST.json')
371
+ if len(sys.argv)==1:
372
+ print(p.read_text() if p.exists() else 'null')
373
+ else:
374
+ if p.is_symlink() or not p.parent.is_dir(): raise SystemExit(2)
375
+ request=json.load(sys.stdin)
376
+ lock=p.parent/'.latest.writer.lock'
377
+ if lock.is_symlink(): raise SystemExit(2)
378
+ with lock.open('a') as guard:
379
+ fcntl.flock(guard,fcntl.LOCK_EX)
380
+ current=json.loads(p.read_text()) if p.exists() else None
381
+ if current!=request['expected'] and current!=request['value']: raise SystemExit(3)
382
+ if current!=request['value']:
383
+ with tempfile.NamedTemporaryFile(mode='w',dir=p.parent,prefix='.latest-',delete=False) as f:
384
+ json.dump(request['value'],f,sort_keys=True); f.write('\\n'); f.flush(); os.fsync(f.fileno()); name=f.name
385
+ os.replace(name,p)
386
+ print('ok')'''
387
+ command = shlex.join(['python3', '-B', '-c', code] + (['write'] if value is not None else []))
388
+ result = subprocess.run(['ssh', '-o', 'BatchMode=yes', REMOTE, command],
389
+ input=_bytes({'expected': expected, 'value': value}).decode() if value is not None else None,
390
+ capture_output=True, text=True, check=False)
391
+ if result.returncode:
392
+ raise UpdateError('remote_latest_failed')
393
+ return None if value is not None else json.loads(result.stdout)
394
+
395
+
396
+ def _hf_api():
397
+ os.environ['HF_HUB_ENABLE_HF_TRANSFER'] = '0'
398
+ os.environ['HF_HUB_DISABLE_XET'] = '1'
399
+ from huggingface_hub import HfApi, get_token
400
+ from huggingface_hub import constants
401
+ constants.HF_HUB_ENABLE_HF_TRANSFER = False
402
+ constants.HF_HUB_DISABLE_XET = True
403
+ if not get_token():
404
+ raise UpdateError('existing_hf_auth_missing')
405
+ return HfApi(token=True)
406
+
407
+
408
+ def _hf_latest(api: Any) -> dict[str, Any] | None:
409
+ from huggingface_hub import hf_hub_download
410
+ path = PREFIX + '/LATEST.json'
411
+ head = api.repo_info(repo_id='junidude14/PBISC-data', repo_type='dataset', revision='main').sha
412
+ try:
413
+ file = hf_hub_download(repo_id='junidude14/PBISC-data', repo_type='dataset',
414
+ filename=path, revision=head, token=True)
415
+ except Exception as exc:
416
+ # Absence is allowed only when the path is absent in the pinned tree.
417
+ if _publisher().base.remote_file(api, 'junidude14/PBISC-data', 'dataset', path, head) is None:
418
+ return None
419
+ raise UpdateError('hf_latest_read_failed') from exc
420
+ return json.loads(Path(file).read_text(encoding='utf-8'))
421
+
422
+
423
+ def _hf_upload_verified(api: Any, path: Path, remote_path: str, *,
424
+ mutable: bool = False, expected_parent: dict[str, Any] | None = None) -> str:
425
+ digest = hashlib.sha256(path.read_bytes()).hexdigest()
426
+ from huggingface_hub import CommitOperationAdd, hf_hub_download
427
+ repo = 'junidude14/PBISC-data'
428
+ head = api.repo_info(repo_id=repo, repo_type='dataset', revision='main').sha
429
+ found = _publisher().base.remote_file(api, repo, 'dataset', remote_path, head)
430
+ if found is not None:
431
+ existing = hf_hub_download(repo_id=repo, repo_type='dataset', filename=remote_path,
432
+ revision=head, token=True)
433
+ existing_bytes = Path(existing).read_bytes()
434
+ if hashlib.sha256(existing_bytes).hexdigest() == digest:
435
+ return head
436
+ if not mutable:
437
+ raise UpdateError('immutable_hf_record_conflict')
438
+ if json.loads(existing_bytes) != expected_parent:
439
+ raise UpdateError('hf_latest_parent_changed')
440
+ elif mutable and expected_parent is not None:
441
+ raise UpdateError('hf_latest_parent_changed')
442
+ result = api.create_commit(repo_id=repo, repo_type='dataset',
443
+ operations=[CommitOperationAdd(path_in_repo=remote_path,
444
+ path_or_fileobj=str(path))],
445
+ commit_message='Publish PBISC-diffusion maintenance record',
446
+ parent_commit=head)
447
+ revision = result.oid
448
+ downloaded = hf_hub_download(repo_id='junidude14/PBISC-data', repo_type='dataset',
449
+ filename=remote_path, revision=revision, token=True)
450
+ if hashlib.sha256(Path(downloaded).read_bytes()).hexdigest() != digest:
451
+ raise UpdateError('hf_record_digest_mismatch')
452
+ return revision
453
+
454
+
455
+ def _verify_rows(root: Path, identifier: str, rows: list[dict[str, Any]],
456
+ frozen_replay: bool = False) -> list[dict[str, Any]]:
457
+ paper = _publisher()
458
+ api = _hf_api()
459
+ revisions = {}
460
+ for repo_type, repo_id in {(r['repo_type'], r['repo_id']) for r in rows}:
461
+ paper.check_visibility(api, repo_id, repo_type)
462
+ revisions[repo_type] = api.repo_info(repo_id=repo_id, repo_type=repo_type, revision='main').sha
463
+ verified = []
464
+ from huggingface_hub import hf_hub_download
465
+ for row in rows:
466
+ if not row['bundle_path'].startswith('updates/' + identifier + '/'):
467
+ raise UpdateError('bundle_outside_update')
468
+ if not frozen_replay and paper.source_digest(row) != row['sha256']:
469
+ raise UpdateError('source_changed')
470
+ inspected = paper.remote_call(paper.archive_request(row, row['sha256'], 'inspect'))
471
+ if inspected.get('event') != 'verified_existing' or not isinstance(inspected.get('stat'), dict):
472
+ raise UpdateError('archive_not_verified')
473
+ revision = revisions[row['repo_type']]
474
+ info = paper.base.remote_file(api, row['repo_id'], row['repo_type'], row['remote_path'], revision)
475
+ if info is None or paper.base.attr(info, 'size') != row['bytes']:
476
+ raise UpdateError('hf_payload_missing')
477
+ lfs = paper.base.attr(info, 'lfs')
478
+ if lfs is not None:
479
+ if paper.base.attr(lfs, 'sha256') != row['sha256']:
480
+ raise UpdateError('hf_payload_digest_mismatch')
481
+ else:
482
+ local = hf_hub_download(repo_id=row['repo_id'], repo_type=row['repo_type'],
483
+ filename=row['remote_path'], revision=revision, token=True)
484
+ if hashlib.sha256(Path(local).read_bytes()).hexdigest() != row['sha256']:
485
+ raise UpdateError('hf_payload_digest_mismatch')
486
+ verified.append(dict(row, archive_stat=inspected['stat'], hf_revision=revision))
487
+ return verified
488
+
489
+
490
+ def _refresh_catalog(root: Path) -> None:
491
+ import importlib.util
492
+ module_path = root / 'maintenance' / 'catalog.py'
493
+ if not module_path.is_file():
494
+ raise UpdateError('catalog_module_missing')
495
+ spec = importlib.util.spec_from_file_location('pbisc_diffusion_catalog', module_path)
496
+ if spec is None or spec.loader is None:
497
+ raise UpdateError('catalog_module_invalid')
498
+ module = importlib.util.module_from_spec(spec)
499
+ spec.loader.exec_module(module)
500
+ module.refresh(root)
501
+
502
+
503
+ def _archive_control(root: Path, identifier: str, folder: Path) -> list[dict[str, Any]]:
504
+ """Keep independent server_2 copies of the post-publish proof and receipts."""
505
+ paper = _publisher()
506
+ required = [folder / 'manifest.json', folder / 'work' / 'receipts.jsonl',
507
+ folder / 'work' / 'status.json', folder / 'UPDATE_VERIFIED.json']
508
+ archived = []
509
+ for source in required:
510
+ _safe_local(source)
511
+ snap = paper.base.snapshot(source.lstat())
512
+ with paper.base.open_source(source, snap) as stream:
513
+ digest = paper.base.hash_source(source, stream, snap)
514
+ bundle = str(PurePosixPath('updates') / identifier / 'control' / source.name)
515
+ row = {'host': 'server_1', 'source': str(source), 'bundle_path': bundle,
516
+ 'bytes': snap['size'], 'expected_stat': snap, 'sha256': digest['sha256'],
517
+ 'repo_type': None, 'repo_id': None, 'remote_path': None}
518
+ result = paper.archive_asset(row, digest['sha256'], True)
519
+ if result.get('event') not in ('verified_existing', 'archived'):
520
+ raise UpdateError('control_archive_failed')
521
+ inspection = paper.remote_call(paper.archive_request(row, digest['sha256'], 'inspect'))
522
+ if inspection.get('event') != 'verified_existing':
523
+ raise UpdateError('control_archive_failed')
524
+ archived.append({'bundle_path': bundle, 'sha256': digest['sha256'],
525
+ 'bytes': snap['size'], 'archive_stat': inspection.get('stat')})
526
+ return archived
527
+
528
+
529
+ def _check_publisher_receipts(folder: Path, rows: list[dict[str, Any]]) -> None:
530
+ receipts = folder / 'work' / 'receipts.jsonl'
531
+ state = folder / 'work' / 'status.json'
532
+ _safe_local(receipts)
533
+ _safe_local(state)
534
+ if _json(state).get('phase') != 'complete' or _json(state).get('execute') is not True:
535
+ raise UpdateError('publisher_status_incomplete')
536
+ events = [json.loads(line) for line in receipts.read_text(encoding='utf-8').splitlines() if line.strip()]
537
+ for row in rows:
538
+ archived = any(event.get('event') in ('archived', 'verified_existing')
539
+ and event.get('bundle_path') == row['bundle_path']
540
+ and event.get('source') == row['source']
541
+ and event.get('sha256') == row['sha256'] for event in events)
542
+ uploaded = any(event.get('event') in ('verified_uploaded', 'verified_existing')
543
+ and event.get('remote_path') == row['remote_path']
544
+ and event.get('repo_id') == row['repo_id']
545
+ and (event.get('sha256') == row['sha256']
546
+ or event.get('digest', {}).get('sha256') == row['sha256'])
547
+ for event in events)
548
+ if not archived or not uploaded:
549
+ raise UpdateError('publisher_receipt_missing')
550
+
551
+
552
+ def _compare_receipt(manifest: dict[str, Any], receipt: dict[str, Any],
553
+ current_rows: list[dict[str, Any]], manifest_bytes: bytes) -> None:
554
+ if (receipt.get('status') != 'PASS' or receipt.get('project_id') != 'pbisc-diffusion'
555
+ or receipt.get('update_id') != manifest.get('update_id')
556
+ or receipt.get('parent_latest') != manifest.get('parent_latest')
557
+ or receipt.get('manifest_sha256') != hashlib.sha256(manifest_bytes).hexdigest()
558
+ or len(receipt.get('assets', [])) != len(current_rows)):
559
+ raise UpdateError('verified_receipt_mismatch')
560
+ for declared, verified, current in zip(manifest['assets'], receipt['assets'], current_rows):
561
+ if (any(verified.get(key) != value for key, value in declared.items())
562
+ or any(verified.get(key) != value for key, value in current.items() if key != 'hf_revision')):
563
+ raise UpdateError('verified_receipt_mismatch')
564
+
565
+
566
+ def _parent_ref(parent: dict[str, Any] | None) -> dict[str, Any] | None:
567
+ if parent is None:
568
+ return None
569
+ return {key: parent[key] for key in ('id', 'verified_receipt_sha256', 'receipt_revision')}
570
+
571
+
572
+ def _validate_manifest_rows(root: Path, folder: Path, manifest: dict[str, Any],
573
+ scope: dict[str, Any], already_latest: bool,
574
+ frozen_replay: bool = False) -> None:
575
+ request = _json(folder / 'request.json')
576
+ if request.get('project_id') != 'pbisc-diffusion' or not isinstance(request.get('assets'), list):
577
+ raise UpdateError('prepared_request_invalid')
578
+ identifier = manifest['update_id']
579
+ declared = manifest['assets']
580
+ selected = {(row['host'], row['source']) for row in declared
581
+ if row.get('category') != 'update_metadata'}
582
+ if len(selected) != len([row for row in declared if row.get('category') != 'update_metadata']):
583
+ raise UpdateError('manifest_duplicate_source')
584
+ if frozen_replay:
585
+ requested = {(item.get('host'), item.get('source'), item.get('kind'), item.get('state'))
586
+ for item in request['assets'] if isinstance(item, dict)}
587
+ payload = [row for row in declared if row.get('category') != 'update_metadata']
588
+ metadata = [_metadata_row(folder / name, identifier, name)
589
+ for name in ('request.json', 'inference_locations.json', 'NOTE.md')]
590
+ if (len(requested) != len(request['assets']) or
591
+ any((row['host'], row['source'], row['category'], row['state']) not in requested
592
+ for row in payload) or declared[-3:] != metadata):
593
+ raise UpdateError('manifest_row_scope_mismatch')
594
+ return
595
+ history = {} if already_latest else _history(root)
596
+ expected = []
597
+ seen = set()
598
+ for item in request['assets']:
599
+ if not isinstance(item, dict) or item.get('host') not in ('server_1', 'server_2') or item.get('state') not in STATES:
600
+ raise UpdateError('prepared_request_invalid')
601
+ host = item['host']
602
+ path = _path(item.get('source'), host)
603
+ key = (host, str(path))
604
+ if key in seen:
605
+ raise UpdateError('prepared_request_duplicate')
606
+ seen.add(key)
607
+ kind = item.get('kind')
608
+ if not isinstance(kind, str):
609
+ raise UpdateError('prepared_request_invalid')
610
+ row = _row(host, path, kind, identifier, scope)
611
+ include = key in selected if already_latest else history.get(key) != row['sha256']
612
+ if include:
613
+ row['state'] = item['state']
614
+ expected.append(row)
615
+ expected.extend([_metadata_row(folder / 'request.json', identifier, 'request.json'),
616
+ _metadata_row(folder / 'inference_locations.json', identifier, 'inference_locations.json'),
617
+ _metadata_row(folder / 'NOTE.md', identifier, 'NOTE.md')])
618
+ if declared != expected:
619
+ raise UpdateError('manifest_row_scope_mismatch')
620
+
621
+
622
+ def publish(root: Path, identifier: str, *, execute: bool,
623
+ publisher: Callable[[Path, str, Path, Path], int] = _run_publisher) -> dict[str, Any]:
624
+ root = root.absolute()
625
+ if not ID_RE.fullmatch(identifier):
626
+ raise UpdateError('invalid_update_id')
627
+ if not execute:
628
+ raise UpdateError('publish_requires_execute')
629
+ scope = _scope(root)
630
+ folder = root / 'maintenance' / 'updates' / identifier
631
+ if (folder.parent.is_symlink() or folder.is_symlink()
632
+ or (folder / 'manifest.json').is_symlink()):
633
+ raise UpdateError('unsafe_update_folder')
634
+ manifest = _json(folder / 'manifest.json')
635
+ manifest_bytes = (folder / 'manifest.json').read_bytes()
636
+ if manifest.get('project_id') != 'pbisc-diffusion' or manifest.get('update_id') != identifier:
637
+ raise UpdateError('manifest_identity_mismatch')
638
+ rows = manifest['assets']
639
+ if not rows or any(not r.get('bundle_path', '').startswith('updates/' + identifier + '/diffusion/') for r in rows):
640
+ raise UpdateError('manifest_bundle_scope')
641
+ # Revalidate every source and repository mapping before calling the broad frozen publisher.
642
+ for row in rows:
643
+ host, path = row['host'], _path(row['source'], row['host'])
644
+ area = _allow(path, host, scope, internal=folder)
645
+ if area == 'internal' and path not in {folder / 'request.json', folder / 'inference_locations.json', folder / 'NOTE.md'}:
646
+ raise UpdateError('unsafe_internal_source')
647
+ if area != 'internal' and row['repo_type'] == 'model' and area != 'model8':
648
+ raise UpdateError('checkpoint_outside_model8')
649
+ expected_repo = 'junidude14/PBISC' if row['repo_type'] == 'model' else 'junidude14/PBISC-data'
650
+ if row['repo_id'] != expected_repo or row['remote_path'] != PREFIX + '/' + row['bundle_path']:
651
+ raise UpdateError('manifest_repository_scope')
652
+ if host == 'server_1':
653
+ _safe_local(path)
654
+ lock_path = root / 'maintenance' / '.writer.lock'
655
+ if lock_path.is_symlink():
656
+ raise UpdateError('unsafe_writer_lock')
657
+ with lock_path.open('a', encoding='utf-8') as lock:
658
+ try:
659
+ fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
660
+ except BlockingIOError as exc:
661
+ raise UpdateError('writer_busy') from exc
662
+ verified_path = folder / 'UPDATE_VERIFIED.json'
663
+ current = _latest(root)
664
+ already_latest = isinstance(current, dict) and current.get('id') == identifier
665
+ if current != manifest.get('parent_latest') and not already_latest:
666
+ raise UpdateError('parent_changed')
667
+ candidate_path = folder / 'LATEST.json'
668
+ frozen_replay = False
669
+ if verified_path.exists() and candidate_path.exists():
670
+ candidate = _json(candidate_path)
671
+ if candidate.get('id') == identifier and _remote_latest() == candidate:
672
+ digest = hashlib.sha256(verified_path.read_bytes()).hexdigest()
673
+ from huggingface_hub import hf_hub_download
674
+ pinned = hf_hub_download(repo_id='junidude14/PBISC-data', repo_type='dataset',
675
+ filename=PREFIX + '/updates/' + identifier + '/UPDATE_VERIFIED.json',
676
+ revision=candidate['receipt_revision'], token=True)
677
+ if candidate.get('verified_receipt_sha256') != digest or hashlib.sha256(Path(pinned).read_bytes()).hexdigest() != digest:
678
+ raise UpdateError('frozen_receipt_mismatch')
679
+ frozen_replay = True
680
+ _validate_manifest_rows(root, folder, manifest, scope, already_latest, frozen_replay)
681
+ status = folder / 'STATUS.json'
682
+ if already_latest:
683
+ if (not verified_path.exists()
684
+ or current.get('verified_receipt_sha256') != hashlib.sha256(verified_path.read_bytes()).hexdigest()):
685
+ raise UpdateError('latest_without_verified_receipt')
686
+ _check_publisher_receipts(folder, rows)
687
+ _compare_receipt(manifest, _json(verified_path),
688
+ _verify_rows(root, identifier, rows, frozen_replay), manifest_bytes)
689
+ api = _hf_api()
690
+ if _remote_latest() != current or _hf_latest(api) != current:
691
+ raise UpdateError('latest_replica_disagreement')
692
+ try:
693
+ _refresh_catalog(root)
694
+ except Exception as exc:
695
+ _atomic(status, _bytes({'phase': 'catalog_pending', 'update_id': identifier}))
696
+ raise UpdateError('catalog_refresh_failed') from exc
697
+ _atomic(status, _bytes({'phase': 'verified', 'update_id': identifier}))
698
+ return current
699
+ _atomic(status, _bytes({'phase': 'publishing', 'update_id': identifier}))
700
+ try:
701
+ if not verified_path.exists():
702
+ if publisher(root, identifier, folder / 'manifest.json', folder / 'work') != 0:
703
+ raise UpdateError('publisher_failed')
704
+ _check_publisher_receipts(folder, rows)
705
+ verified_rows = _verify_rows(root, identifier, rows)
706
+ receipt = {'schema': 'pbisc.diffusion.update-verified.v1', 'status': 'PASS',
707
+ 'project_id': 'pbisc-diffusion', 'update_id': identifier,
708
+ 'parent_latest': manifest.get('parent_latest'),
709
+ 'manifest_sha256': hashlib.sha256(manifest_bytes).hexdigest(),
710
+ 'assets': verified_rows}
711
+ _atomic(verified_path, _bytes(receipt))
712
+ else:
713
+ _check_publisher_receipts(folder, rows)
714
+ _compare_receipt(manifest, _json(verified_path),
715
+ _verify_rows(root, identifier, rows, frozen_replay), manifest_bytes)
716
+ archived_control = _archive_control(root, identifier, folder)
717
+ api = _hf_api()
718
+ remote_latest, hf_latest = _remote_latest(), _hf_latest(api)
719
+ if (remote_latest not in (manifest.get('parent_latest'), _json(folder / 'LATEST.json') if (folder / 'LATEST.json').exists() else None)
720
+ or hf_latest not in (manifest.get('parent_latest'), _json(folder / 'LATEST.json') if (folder / 'LATEST.json').exists() else None)):
721
+ raise UpdateError('parent_changed_remote')
722
+ pointer_path = folder / 'LATEST.json'
723
+ if pointer_path.exists():
724
+ pointer = _json(pointer_path)
725
+ if (pointer.get('id') != identifier or pointer.get('parent') != _parent_ref(manifest.get('parent_latest'))
726
+ or pointer.get('verified_receipt_sha256') != hashlib.sha256(verified_path.read_bytes()).hexdigest()):
727
+ raise UpdateError('prepared_pointer_conflict')
728
+ else:
729
+ receipt_revision = _hf_upload_verified(api, verified_path,
730
+ PREFIX + '/updates/' + identifier + '/UPDATE_VERIFIED.json')
731
+ pointer = {'schema': 'pbisc.diffusion.latest.v1', 'project_id': 'pbisc-diffusion',
732
+ 'id': identifier, 'parent': _parent_ref(manifest.get('parent_latest')),
733
+ 'verified_receipt_path': PREFIX + '/updates/' + identifier + '/UPDATE_VERIFIED.json',
734
+ 'verified_receipt_sha256': hashlib.sha256(verified_path.read_bytes()).hexdigest(),
735
+ 'receipt_revision': receipt_revision, 'control_archive': archived_control}
736
+ _atomic(pointer_path, _bytes(pointer))
737
+ _remote_latest(pointer, expected=manifest.get('parent_latest'))
738
+ _hf_upload_verified(api, pointer_path, PREFIX + '/LATEST.json',
739
+ mutable=True, expected_parent=manifest.get('parent_latest'))
740
+ if _remote_latest() != pointer or _hf_latest(api) != pointer:
741
+ raise UpdateError('latest_replica_disagreement')
742
+ _atomic(root / 'LATEST.json', _bytes(pointer))
743
+ try:
744
+ _refresh_catalog(root)
745
+ except Exception as exc:
746
+ _atomic(status, _bytes({'phase': 'catalog_pending', 'update_id': identifier}))
747
+ raise UpdateError('catalog_refresh_failed') from exc
748
+ _atomic(status, _bytes({'phase': 'verified', 'update_id': identifier}))
749
+ return pointer
750
+ except Exception as exc:
751
+ if not status.exists() or _json(status).get('phase') != 'catalog_pending':
752
+ _atomic(status, _bytes({'phase': 'error', 'update_id': identifier,
753
+ 'error_code': str(exc) if isinstance(exc, UpdateError) else 'update_failed'}))
754
+ raise
755
+
756
+
757
+ def status(root: Path) -> dict[str, Any]:
758
+ _scope(root.absolute())
759
+ updates = []
760
+ updates_root = root / 'maintenance' / 'updates'
761
+ if updates_root.is_symlink():
762
+ raise UpdateError('unsafe_updates_root')
763
+ for folder in sorted(updates_root.glob('*')) if updates_root.exists() else []:
764
+ if folder.is_dir() and not folder.is_symlink() and ID_RE.fullmatch(folder.name):
765
+ state = _json(folder / 'STATUS.json') if (folder / 'STATUS.json').exists() else {'phase': 'unknown'}
766
+ updates.append({'id': folder.name, 'phase': state['phase']})
767
+ baseline = root / 'maintenance' / 'BASELINE_REFERENCE.json'
768
+ return {'project_id': 'pbisc-diffusion', 'latest': _latest(root),
769
+ 'baseline': _json(baseline) if baseline.exists() else None, 'updates': updates}
770
+
771
+
772
+ def main(argv: list[str] | None = None) -> int:
773
+ parser = argparse.ArgumentParser(description=__doc__)
774
+ sub = parser.add_subparsers(dest='command', required=True)
775
+ prep = sub.add_parser('prepare')
776
+ prep.add_argument('--request', required=True, type=Path)
777
+ prep.add_argument('--id', required=True)
778
+ pub = sub.add_parser('publish')
779
+ pub.add_argument('id')
780
+ pub.add_argument('--execute', action='store_true')
781
+ sub.add_parser('status')
782
+ args = parser.parse_args(argv)
783
+ try:
784
+ if args.command == 'prepare':
785
+ request = json.load(sys.stdin) if str(args.request) == '-' else _json(args.request)
786
+ result = {'prepared': str(prepare(ROOT, request, args.id))}
787
+ elif args.command == 'publish':
788
+ result = publish(ROOT, args.id, execute=args.execute)
789
+ else:
790
+ result = status(ROOT)
791
+ print(json.dumps(result, sort_keys=True))
792
+ return 0
793
+ except Exception as exc:
794
+ print(json.dumps({'error_code': str(exc) if isinstance(exc, UpdateError) else 'update_failed'}), file=sys.stderr)
795
+ return 1
796
+
797
+
798
+ if __name__ == '__main__':
799
+ raise SystemExit(main())
paper-releases/pbisc-diffusion/updates/20261007T185408Z-scsemi-cleanup-recovery/diffusion/metadata/inference_locations.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "locations": [],
3
+ "project_id": "pbisc-diffusion",
4
+ "update_id": "20261007T185408Z-scsemi-cleanup-recovery"
5
+ }
paper-releases/pbisc-diffusion/updates/20261007T185408Z-scsemi-cleanup-recovery/diffusion/metadata/request.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "assets": [
3
+ {
4
+ "host": "server_2",
5
+ "kind": "report",
6
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paired_finetune_intradataset_20260927/scsemi/README.md",
7
+ "state": "completed"
8
+ },
9
+ {
10
+ "host": "server_1",
11
+ "kind": "maintenance",
12
+ "source": "/home/sj_server_1/PBISC/paper-release-20260928/maintenance/update.py",
13
+ "state": "completed"
14
+ },
15
+ {
16
+ "host": "server_1",
17
+ "kind": "maintenance",
18
+ "source": "/home/sj_server_1/PBISC/paper-release-20260928/maintenance/test_update.py",
19
+ "state": "completed"
20
+ }
21
+ ],
22
+ "inference_locations": [],
23
+ "project_id": "pbisc-diffusion",
24
+ "summary": "Document verified SCSEMI disk cleanup and repair safe replay of a partially committed PBISC-Diffusion archive update"
25
+ }