Add server-side temporary storage controls for 3.9.3

This commit is contained in:
Miura Yoshiki
2026-10-13 12:18:23 +00:00
parent e9b1294ccd
commit d8fbf287a9
34 changed files with 2288 additions and 66 deletions
+3
View File
@@ -63,3 +63,6 @@ examples/workflows/*
!docs/TIMELINE_VIDEO_EXPERIMENTAL.md !docs/TIMELINE_VIDEO_EXPERIMENTAL.md
!docs/V39_REFERENCE_INLINE.md !docs/V39_REFERENCE_INLINE.md
.h3-timeline-experimental.json .h3-timeline-experimental.json
# Current temporary storage controls and lifecycle contract.
!docs/TEMPORARY_STORAGE_JA.md
+16 -1
View File
@@ -20,8 +20,23 @@ jobs:
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install --index-url https://download.pytorch.org/whl/cpu torch python -m pip install --index-url https://download.pytorch.org/whl/cpu torch
python -m pip install -r requirements.txt numpy safetensors pytest psutil opencv-python-headless Pillow python -m pip install -r requirements.txt numpy safetensors pytest psutil opencv-python-headless Pillow aiohttp
- name: Compile Python - name: Compile Python
run: python -m compileall -q . run: python -m compileall -q .
- name: Run tests - name: Run tests
run: python -m pytest -q -p no:cacheprovider run: python -m pytest -q -p no:cacheprovider
windows-storage:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install CPU storage test dependencies
run: |
python -m pip install --index-url https://download.pytorch.org/whl/cpu torch
python -m pip install numpy safetensors pytest psutil aiohttp
- name: Windows file-backed and temporary storage regressions
run: python -m pytest -q -p no:cacheprovider tests/test_temporary_storage.py tests/test_storage_api.py tests/test_p20_file_backed_tensor_poc.py tests/test_p22_file_backed_buffer.py tests/decode_cache
+1 -1
View File
@@ -2,7 +2,7 @@
## Scope ## Scope
MiniMax H3 Continuum for ComfyUI. Package 3.9.2 provides the V3.9 Sampler and Reference Images helper, while retaining the separate V3.8X2 workflow. Source publication does not imply a GitHub Release or Registry package publication. MiniMax H3 Continuum for ComfyUI. Package 3.9.3 provides the V3.9 Sampler and Reference Images helper, while retaining the separate V3.8X2 workflow. Source publication does not imply a GitHub Release or Registry package publication.
Sampling Contract v6 and Graph Contract v4 apply to new generation. Keep original v5 history readable, without reusing its Takes in v6 generation or rewriting stored manifests. Public node IDs, socket/widget order, official workflows, Run Storage v3 and State/Session formats remain unchanged. Sampling Contract v6 and Graph Contract v4 apply to new generation. Keep original v5 history readable, without reusing its Takes in v6 generation or rewriting stored manifests. Public node IDs, socket/widget order, official workflows, Run Storage v3 and State/Session formats remain unchanged.
+8
View File
@@ -1,5 +1,13 @@
# Changelog # Changelog
## 3.9.3 — temporary storage settings (2026-10-13)
- Add a server-owned scratch folder setting for both Finalize and Decode Cache, with storage candidates, logical file sizes, free space and conservative unused-file cleanup.
- Apply changes to new files while keeping existing outputs and aliases valid. Preserve blank/default paths and explicit internal overrides; never fall back silently to the original disk when a selected drive is unavailable.
- Protect unknown owners, live processes and mapped outputs during cleanup, including outputs whose helper has already been removed. Track new cache directories for dead-process recovery.
- Add manual RAM and Disk-backed capacity checks and account for discoverable Linux cgroup memory limits. Keep Auto's 4 GiB threshold and reserve, existing node controls, frame dtype and generation/storage identities.
- Keep V3.9 and V3.8X2 workflows and public node schemas unchanged. No new GPU generation is claimed for this storage update; see PACKAGE_VALIDATION.txt for CPU/browser/platform coverage.
## 3.9.2 — Issue #30 frontend hotfix (2026-10-13) ## 3.9.2 — Issue #30 frontend hotfix (2026-10-13)
- Skip upstream Review settings snapshots when no comparison baseline exists. Keep drawing-time edit detection and synchronous Queue/Take checks for reviewed settings. - Skip upstream Review settings snapshots when no comparison baseline exists. Keep drawing-time edit detection and synchronous Queue/Take checks for reviewed settings.
+30 -20
View File
@@ -1,19 +1,19 @@
dca65fb1393e67f59c6f81f9411e3e745eb8f1097e9a2adf7ffc6f4e3901ca9f __init__.py 02ea0951ce2e7ac2d5f3bbf02c596a9f9ea8adcdf2a113dca4c8db3cc19c36b3 __init__.py
54ba2a58388c42063d24335aa2737e86bd4c15fe9632dcc9ffba18c328e04641 .comfyignore cb19f6b668d08217621f92ec2cc890e9ba3fbe205d1212e01e6b2dd31a0992de .comfyignore
3d681ded5d4c50cc20c2382e29fdc98d8a48e76d552c41ad5a195d941e66e612 .gitattributes 3d681ded5d4c50cc20c2382e29fdc98d8a48e76d552c41ad5a195d941e66e612 .gitattributes
8296f0afc7be47171e439c02fb2988cfeb0df904acbe3fc4f507f426d709157e .github/workflows/tests.yml 3e22b441fe96bb6d099f0fcb92265f7a986c444f6c45be263c7905898aea4ac7 .github/workflows/tests.yml
a28c4c592d56c57e0967f0adce5655313b942b8cc04f77766c0db1bec96c13e0 .gitignore a28c4c592d56c57e0967f0adce5655313b942b8cc04f77766c0db1bec96c13e0 .gitignore
3e7a1ec3380be2a222c8a3e9b8a6bb184d3a760478957f48186438f15235bdba branch_provenance.py 3e7a1ec3380be2a222c8a3e9b8a6bb184d3a760478957f48186438f15235bdba branch_provenance.py
2839ac42889341b018bc6013cfe7e5cf4cca81f3b80fae0620ac30612a5918e5 CHANGELOG.md 32353be7af0fe26ff5aa2ffbc9e22823f1360af9213f27d5011208294b053b80 CHANGELOG.md
c1ed3a0342730450958fb62fd21854a876991f3a4aefb24e5383b0c73cd2312d compatibility.py c1ed3a0342730450958fb62fd21854a876991f3a4aefb24e5383b0c73cd2312d compatibility.py
4d62508f900af9f93ec320afb900c27cc9a300d1e0c0a94714258498c5ede5fc conditioning.py 4d62508f900af9f93ec320afb900c27cc9a300d1e0c0a94714258498c5ede5fc conditioning.py
294251c40b1be2e296c5e5f627b68091d087bdb39179e3a0c3cebd2ee8a344f5 constants.py 294251c40b1be2e296c5e5f627b68091d087bdb39179e3a0c3cebd2ee8a344f5 constants.py
cf255b8a635471229aebadc926acfdcacb65963adbcb9e0f9505d04eada2c6b5 continuation.py cf255b8a635471229aebadc926acfdcacb65963adbcb9e0f9505d04eada2c6b5 continuation.py
51f1d211dfc36602a006fe5d14f4ebb08182694ad464aa9176340ff7e2bd1e41 decode_cache/__init__.py 51f1d211dfc36602a006fe5d14f4ebb08182694ad464aa9176340ff7e2bd1e41 decode_cache/__init__.py
647f55a9253976c059502dec13c7f64d7f7df1ecbe619d543c973f92f7f36776 decode_cache/identity.py 647f55a9253976c059502dec13c7f64d7f7df1ecbe619d543c973f92f7f36776 decode_cache/identity.py
5e599feee3199ee5dbe00e9dfb05c159cb6fe4c0c1ab19677971ce6b1cf4e34c decode_cache/nodes.py c2b44e3caed54c894556af547cd800328ed287a8cc90e0b5031f34bd6bd2224b decode_cache/nodes.py
986cc7a3dc153ff1b41c427a86756e505ea6e17d8b065df1ab15b8ff904f090e decode_cache/service.py 986cc7a3dc153ff1b41c427a86756e505ea6e17d8b065df1ab15b8ff904f090e decode_cache/service.py
8b79ad007488a085284c401f8c1bb99ca6ee58cf736ec9c029548220e2d8adb9 decode_cache/store.py 630ba3d2183964444c4341a8df507f7af61dac6a8e5aaca8cf387a5376d49f27 decode_cache/store.py
f9375629fa1a2c4d3538442f0c3192d7ba2f46fe9544fb2e21f0c144b53d608c docs/AB_TEST_LOG_JA.md f9375629fa1a2c4d3538442f0c3192d7ba2f46fe9544fb2e21f0c144b53d608c docs/AB_TEST_LOG_JA.md
c93a3e52e4deabe5ef0db7f34a7605856a543089574ba17227e697e9a2c0139a docs/ARCHITECTURE.md c93a3e52e4deabe5ef0db7f34a7605856a543089574ba17227e697e9a2c0139a docs/ARCHITECTURE.md
1d60cf5d4ef9c45885d4f90289c3b17aa70a6a2752c6b288288322a5e0568050 docs/FAILURE_SEMANTICS_BASELINE.md 1d60cf5d4ef9c45885d4f90289c3b17aa70a6a2752c6b288288322a5e0568050 docs/FAILURE_SEMANTICS_BASELINE.md
@@ -89,7 +89,7 @@ ca9f1aecd1032f0f0b237948c7fc1e4e693440dff35f5f17fd5e6d5ca4dab7f9 docs/V38_BEGIN
717577efdec5e61600504b77bc2a099ef022c4fe2333e936c3310c7182d8f2a0 docs/V38_OPEN_INTEGRATION_CONTRACT.md 717577efdec5e61600504b77bc2a099ef022c4fe2333e936c3310c7182d8f2a0 docs/V38_OPEN_INTEGRATION_CONTRACT.md
3496636f645b39336fd95a4f21a562810c56f8e1d92fa6eeb1e4b0786ad11b37 docs/V38_RELEASE_AND_MIGRATION.md 3496636f645b39336fd95a4f21a562810c56f8e1d92fa6eeb1e4b0786ad11b37 docs/V38_RELEASE_AND_MIGRATION.md
4d17d74107e78404b190fec9494b443249e5aff4f58670c50d54dfdfb064334b docs/V39_REFERENCE_INLINE.md 4d17d74107e78404b190fec9494b443249e5aff4f58670c50d54dfdfb064334b docs/V39_REFERENCE_INLINE.md
be4440167361f33659f1f34cc81653989412ab0c5509966d44753edb59816c05 docs/VALIDATION_JA.md 79bf8886f91eb3e8e7e8db8a8093eaa12fbb012b156e8d478de14f089f7c19f4 docs/VALIDATION_JA.md
3fec541a675c1e4e5e287cc8e498036001f34f7a62460321e16f9ba27b5e4c18 docs/VALIDATION_RESULTS.md 3fec541a675c1e4e5e287cc8e498036001f34f7a62460321e16f9ba27b5e4c18 docs/VALIDATION_RESULTS.md
a8c56379abe23b98c8ceed6ea5e60a02ecc3c6d9636232d7371615f4eb306e81 driving_audio.py a8c56379abe23b98c8ceed6ea5e60a02ecc3c6d9636232d7371615f4eb306e81 driving_audio.py
6771c9905d35666121c4892d2ec26202505f96d244ce814ad9a87a02878952cd examples/H3_CONTINUUM_V1_WIRING.md 6771c9905d35666121c4892d2ec26202505f96d244ce814ad9a87a02878952cd examples/H3_CONTINUUM_V1_WIRING.md
@@ -127,21 +127,21 @@ bf0556b076dbaca67c3405a7d86c333ca7fdf3d4381529b0a9edc906519943e9 guide_timeline
139546ec1ff459945aa89b50f74b5ee69f62a0e07bbddfcae06936091a409a83 layout_adapter.py 139546ec1ff459945aa89b50f74b5ee69f62a0e07bbddfcae06936091a409a83 layout_adapter.py
c44abbd789091bbead01250dbd5453e60539d2665c69f162335fdbd2936019c2 LICENSE c44abbd789091bbead01250dbd5453e60539d2665c69f162335fdbd2936019c2 LICENSE
d3e213005670e94dee33a240349a4d245cf9a3b6602099f11ed30cf5a32e2c21 media.py d3e213005670e94dee33a240349a4d245cf9a3b6602099f11ed30cf5a32e2c21 media.py
a4b2b73c50ad05e4d6711e5db4a58c12cb98177ced27d29b2fb4e247761c5c01 metadata.ini 34eca7ac7be8c9ab7a67808d7cdb6f2b0ef54ba67d74cad036617a60663cff16 metadata.ini
fd23c7f32810788aaaf1709c4959c40ec72303aecc6f6afa5fa68d824cca97a8 minimax-h3-continuum-dance-director.zip fd23c7f32810788aaaf1709c4959c40ec72303aecc6f6afa5fa68d824cca97a8 minimax-h3-continuum-dance-director.zip
d7e613e2cc24110213b477bdd1d390234a41f2af3b1ed006a809066d71d658eb model_patch.py d7e613e2cc24110213b477bdd1d390234a41f2af3b1ed006a809066d71d658eb model_patch.py
ecb65a5dbf9e1683c5a3cadd82daaea3a90a2b776f6ebabfbe8b07aa93177422 nodes.py ecb65a5dbf9e1683c5a3cadd82daaea3a90a2b776f6ebabfbe8b07aa93177422 nodes.py
cd187770a30eba87f576da9baa7de8fb53ebfc7e739e8412e1558bf7ed161660 PACKAGE_INFO_JA.txt f67982dd107c1c37c033a860adab343b86390af4ff94bc20f16c836f6dc8915d PACKAGE_INFO_JA.txt
3b729a12c3b89f88055267ef6a14e9df71752fa2d0c4d586d0e8b96a05d3ed7c PACKAGE_VALIDATION.txt e71abe10be665cf58a5f07cd2eea45b3f94ea06443616daadfa2b7c44e3d71de PACKAGE_VALIDATION.txt
b470819f16fc179654dc1600721a63f0a5a14e777f4c004d574b499da6886ba5 public_api.py b470819f16fc179654dc1600721a63f0a5a14e777f4c004d574b499da6886ba5 public_api.py
ffbe4240d104d360c280a5d4743432520c265f1021c5f4668a977b22a6a8bddb pyproject.toml e6190cc7b2ce1adcaa37e221c2edca1f257ca516a80003d6ea87b2e146e028f9 pyproject.toml
94fdc2d545b2d4077a4d70229fd22ba3ccac21d49d1097d2873f76d04e9a3c7a pytest.ini 94fdc2d545b2d4077a4d70229fd22ba3ccac21d49d1097d2873f76d04e9a3c7a pytest.ini
65daf6eb0585c4850a0d306a00b801f9f356583f25e23be327f2dc7e98d7cdbd README_JA.md 7b5dde75e41dbc133c6958dcbf54ce381c10e7e1fef253100019bd7e14c7fb47 README_JA.md
9f60c0074efa406611a7433489d87f8b0e7bfbb9e1649b5bf14232ce9dc98641 README.md c1a40d0ed6ffb2cbe893b92677de50e871bcfc8456753656b466540129224174 README.md
9539f5cb9fb695841073fa58d9246d5a7410bc372f6cd340378185004dfaf978 reference_audio.py 9539f5cb9fb695841073fa58d9246d5a7410bc372f6cd340378185004dfaf978 reference_audio.py
5cb9bfd6810d3a93a637451980a4cc5c1436e5b84cfd1c7a111cd192e876351b reference_video.py 5cb9bfd6810d3a93a637451980a4cc5c1436e5b84cfd1c7a111cd192e876351b reference_video.py
caa572ea65dafc86850db99f52433d360ac9c4ab36b854292a3dccd5ba32dc76 reference.py caa572ea65dafc86850db99f52433d360ac9c4ab36b854292a3dccd5ba32dc76 reference.py
8f59c2eb987b5a886d4c3a2031f0def8794a99ba564ac31e18245db8f5c3a423 REGISTRY_MANIFEST.sha256 b03dca829ef2e380e7cd030b54f8a8f81cea7f5d81ee7536c0f3fd661ee84bf2 REGISTRY_MANIFEST.sha256
467edb2c188d024c2392aafe7423b3f835e16b10f570da76e2f7dda8a962c1c5 requirements.txt 467edb2c188d024c2392aafe7423b3f835e16b10f570da76e2f7dda8a962c1c5 requirements.txt
1845cbf7ba4d3b35afd087a15f5a4d92dc73d4858e61982f8ccf431a836a22b1 run_storage.py 1845cbf7ba4d3b35afd087a15f5a4d92dc73d4858e61982f8ccf431a836a22b1 run_storage.py
6056de6c0a5322a8a51ba5a114538dca2ef67788cd1afba10fedd483b95f6afa state_io.py 6056de6c0a5322a8a51ba5a114538dca2ef67788cd1afba10fedd483b95f6afa state_io.py
@@ -193,7 +193,7 @@ c2560cbafc5962bce5f063e262cf6a173dd8df18f7b58035ec326f616617d61c tests/test_p25
2d16f6de7bcaf1f92718d3719654a746438f6218bba8d25b3632c318a1ab9c98 tests/test_packed_layout_preflight.py 2d16f6de7bcaf1f92718d3719654a746438f6218bba8d25b3632c318a1ab9c98 tests/test_packed_layout_preflight.py
1ae0369943ba2fb13f21ad0cf56ee58621ba09bf20174379595e157a1775c7fd tests/test_public_api.py 1ae0369943ba2fb13f21ad0cf56ee58621ba09bf20174379595e157a1775c7fd tests/test_public_api.py
892d3e3e022a527652dd995508c8bbb650c370caf9ee66fa3eb1f7fd288bba38 tests/test_public_workflow_integrity.py 892d3e3e022a527652dd995508c8bbb650c370caf9ee66fa3eb1f7fd288bba38 tests/test_public_workflow_integrity.py
1be35d57f4550de029cb3c8a06378183982dacda7736681e95f0d3f4c29cf8bf tests/test_release_metadata.py 52799fffb39d69ef294300551fbde77a6de075d79179da0f8c59accc3c787833 tests/test_release_metadata.py
5f6caf1814052798f20571ebb863c098bec23d8f2e091fc1f30ce1ef9c58675a tests/test_review_identity_lifecycle.py 5f6caf1814052798f20571ebb863c098bec23d8f2e091fc1f30ce1ef9c58675a tests/test_review_identity_lifecycle.py
5f7d3e01bc78fa076ecb17f8532b6d3f3137545da4028032ad6769407d80be07 tests/test_review_provenance_reroll.py 5f7d3e01bc78fa076ecb17f8532b6d3f3137545da4028032ad6769407d80be07 tests/test_review_provenance_reroll.py
d5e255a5fdd06ea18e70f4077f855ed2f02664f91caf79b66bfbdf7df44ad07b tests/test_review_rehydration.py d5e255a5fdd06ea18e70f4077f855ed2f02664f91caf79b66bfbdf7df44ad07b tests/test_review_rehydration.py
@@ -217,7 +217,7 @@ b42bcc0983147462d96c6b71cc4a38e846995dafa6eebefc3ae0d9bb36caf359 tests/test_v2_
0b5b20a8318862d167f135720e0489b8d4f93406d67c6646e052e35b03dcb876 tests/test_v2_session.py 0b5b20a8318862d167f135720e0489b8d4f93406d67c6646e052e35b03dcb876 tests/test_v2_session.py
b5c320279fd38d2038e39951a3d016aa9b80741523d2816e01ceda1bdecb71b8 tests/test_v2_terminal_merge.py b5c320279fd38d2038e39951a3d016aa9b80741523d2816e01ceda1bdecb71b8 tests/test_v2_terminal_merge.py
e22486ac62c53132c275614e4e161c78e6dce09dd0d1a7cf64f641a3b7052b99 tests/test_v2_widget_migration.py e22486ac62c53132c275614e4e161c78e6dce09dd0d1a7cf64f641a3b7052b99 tests/test_v2_widget_migration.py
f8c363b1700e6f84f612aa3478e14fdbdfb881107dfeabb81a124e5413f080c2 tests/test_v217_stable_facade.py b8e04e6cd54a90a4ae24efdbcffdbd69e18c9aa05d2033b33233aa26da94f9e7 tests/test_v217_stable_facade.py
473abac48a57aa5f297c6e141a94de17ddcb9424a8744bae1c46e6a6a734a0ab tests/test_v3_hardening.py 473abac48a57aa5f297c6e141a94de17ddcb9424a8744bae1c46e6a6a734a0ab tests/test_v3_hardening.py
9242f74663ccb04020ad2fb1199990c84433c9b4c5cf0560e93416c7b15e1913 tests/test_v3_physical_decode_groups.py 9242f74663ccb04020ad2fb1199990c84433c9b4c5cf0560e93416c7b15e1913 tests/test_v3_physical_decode_groups.py
35b26c8cade7acb2eec35375d7dfa9a4a112f67a5cec6a842d61c69039de0d84 tests/test_v3_video_seam.py 35b26c8cade7acb2eec35375d7dfa9a4a112f67a5cec6a842d61c69039de0d84 tests/test_v3_video_seam.py
@@ -304,7 +304,7 @@ e922c8737c8e4a1d62299d27391c0496ecec83c0e9f26600b2039f83b8272b18 tools/issue13_
c315aacb3fbe6dc8a38c50cfb336760ee2fd3c293d80617360c3f3b639ae2053 tools/issue13_r25_gate_runner.py c315aacb3fbe6dc8a38c50cfb336760ee2fd3c293d80617360c3f3b639ae2053 tools/issue13_r25_gate_runner.py
f03916a76a1c1489fd7a23d234a04d0f26fa8afb49a409e0fea779b9fac71a11 tools/issue13_r28_analyze.py f03916a76a1c1489fd7a23d234a04d0f26fa8afb49a409e0fea779b9fac71a11 tools/issue13_r28_analyze.py
ab4b007df62fc09a6d346dcb8c5171c8ea8b6e56e487720ef9fb91ddf19014d3 tools/issue13_r28_gate_runner.py ab4b007df62fc09a6d346dcb8c5171c8ea8b6e56e487720ef9fb91ddf19014d3 tools/issue13_r28_gate_runner.py
e5a84569953ee63b9625f4f2e3195ec368204fddcfc746564cfbd0e8449bb8e9 tools/p20_file_backed_tensor_poc.py 2743597d289d9eb12334d1f5cdd630497e237814ddf48b17f6f68da299c01150 tools/p20_file_backed_tensor_poc.py
3bf6dfddb9a0e5276613e505465d0f01442035940c0806a3ca64daf7753a8592 tools/p24_comfy_integration_probe.py 3bf6dfddb9a0e5276613e505465d0f01442035940c0806a3ca64daf7753a8592 tools/p24_comfy_integration_probe.py
6277e2aad67ddc9b446c9883a33e72b5194a053e5b814a9a935ce7a7770d8793 tools/p25_gpu_acceptance_probe.py 6277e2aad67ddc9b446c9883a33e72b5194a053e5b814a9a935ce7a7770d8793 tools/p25_gpu_acceptance_probe.py
5d59c7a9c83639e1a0dc1b52ceb439586c778fbb241edd552c0f165013308bdd tools/p32_api_runner.py 5d59c7a9c83639e1a0dc1b52ceb439586c778fbb241edd552c0f165013308bdd tools/p32_api_runner.py
@@ -353,7 +353,7 @@ be0d8585fa57e0ccd6d02577bbc7299629e5bfe20e186747f571fccc98b67d7e v2/seam_types.
3ea23dbce6fcd217b6e81235855479b9b16fed7a21693cf156f9014555c4fe13 v2/session.py 3ea23dbce6fcd217b6e81235855479b9b16fed7a21693cf156f9014555c4fe13 v2/session.py
78c830cdf49034c6e3b2cd3da5914d5cfc5638eb63ec6dbd1bab13c50d6d4caf v3/__init__.py 78c830cdf49034c6e3b2cd3da5914d5cfc5638eb63ec6dbd1bab13c50d6d4caf v3/__init__.py
ea2922567df90436dd6fa21696833a49dd0cbfeee142a5fedc3a7c303824d473 v3/adaptive_continuity.py ea2922567df90436dd6fa21696833a49dd0cbfeee142a5fedc3a7c303824d473 v3/adaptive_continuity.py
c03f9f6307b5e3a658fe6d94b01b48bbf5726737e1a8979d6d6f374965f2dc50 v3/assembly_v35.py 70bec17d0dce1873b9bb4a51b09daf76833722ce89f005a22b029533a367e62b v3/assembly_v35.py
7815230e0a9540bc2edeaf818e940b7a1fdd817fd217ba8a4f9cb21aaf6a308e v3/assembly.py 7815230e0a9540bc2edeaf818e940b7a1fdd817fd217ba8a4f9cb21aaf6a308e v3/assembly.py
3f62fdb35e804f42d7cbf0828b4e87e69a2b99246c3f7467fe4fa698f1d803c9 v3/conditioning_bridge_nodes.py 3f62fdb35e804f42d7cbf0828b4e87e69a2b99246c3f7467fe4fa698f1d803c9 v3/conditioning_bridge_nodes.py
fa7a355e52fbcfe1f53b16fa1c37af5d839215b49412adb41c90129ae4e9d9f7 v3/driving_nodes.py fa7a355e52fbcfe1f53b16fa1c37af5d839215b49412adb41c90129ae4e9d9f7 v3/driving_nodes.py
@@ -362,7 +362,7 @@ fa7a355e52fbcfe1f53b16fa1c37af5d839215b49412adb41c90129ae4e9d9f7 v3/driving_nod
ac859cb1a6e23b8ceae300d818c24fe1346b649a0d663017a9b3ac64aa96fca3 v3/easy_nodes.py ac859cb1a6e23b8ceae300d818c24fe1346b649a0d663017a9b3ac64aa96fca3 v3/easy_nodes.py
11e9daa45237392ac84ac1b54b3e8d5e980e77102779831824794a2a6675500b v3/easy_video_nodes.py 11e9daa45237392ac84ac1b54b3e8d5e980e77102779831824794a2a6675500b v3/easy_video_nodes.py
fe03ae0aa0dbbbe5f950bb7da34c18a078d841547992c374ea8beda5e3ad4715 v3/execution_planner.py fe03ae0aa0dbbbe5f950bb7da34c18a078d841547992c374ea8beda5e3ad4715 v3/execution_planner.py
6cc7ed74666084c55beb9075304e92a9defafd81b9c6678239ca3859a08cddd7 v3/file_backed_buffer.py 69bf49d0601edbe51730b9d409b1cde647feabde0bde561e416b0b472a27f4e6 v3/file_backed_buffer.py
cb53e1b104415032ec79b7e7aa1c99848e63da3eedaa251eeba102970e4172b5 v3/hires_fix_nodes.py cb53e1b104415032ec79b7e7aa1c99848e63da3eedaa251eeba102970e4172b5 v3/hires_fix_nodes.py
0858487e2b8c0060a856273ffc65d23165b2f253d183f506e27e419aea0da561 v3/latent_resize_nodes.py 0858487e2b8c0060a856273ffc65d23165b2f253d183f506e27e419aea0da561 v3/latent_resize_nodes.py
5b8a54e67a608e757a505abc712effb33312636e3bb235835a485a506e80eeee v3/masked_continuation.py 5b8a54e67a608e757a505abc712effb33312636e3bb235835a485a506e80eeee v3/masked_continuation.py
@@ -400,7 +400,7 @@ d0a004aa3030c8adaa5ea788f9acc758fcb4a556f203f9a3f63fa4e4b5772063 v3/sampling_en
26b13614ba0a5fd8b192a106c9503b2f4b6fe7f9268a0fcb0f544979a49cab34 v3/video_adapter_nodes.py 26b13614ba0a5fd8b192a106c9503b2f4b6fe7f9268a0fcb0f544979a49cab34 v3/video_adapter_nodes.py
4178dcfa442abdb06ce276e05bd7bcbaa6da28469ba5e57d3da3c663de4e4a9d v3/video_seam_v35.py 4178dcfa442abdb06ce276e05bd7bcbaa6da28469ba5e57d3da3c663de4e4a9d v3/video_seam_v35.py
2f07ace1462644f0bee553827b3571535de4d0c2d9ef847bd9e0ca73a4eed5cb v3/video_seam.py 2f07ace1462644f0bee553827b3571535de4d0c2d9ef847bd9e0ca73a4eed5cb v3/video_seam.py
76db0e3f2bba3e72050c6e35c47a1460fc5a74203d82aa63118b3f4e06ae4ac3 version.py 2f677bcbd9a65c7f462e315936bd2de491429a1583475be24a211db768cfc8b8 version.py
b935ad3bb729948bb3890ce967b0ecbef737a5e51ddfc47a0060fc20aa78dcda video_reference_modes.py b935ad3bb729948bb3890ce967b0ecbef737a5e51ddfc47a0060fc20aa78dcda video_reference_modes.py
685df8e0fa23e3663ab31da1e4470cd19bdaa0dc16362cb606e874d9d6153c2c web/decode_cache_helper.js 685df8e0fa23e3663ab31da1e4470cd19bdaa0dc16362cb606e874d9d6153c2c web/decode_cache_helper.js
fefafd4550511d80bd85ade46a0476f0cf3de13ddb94a908dff6b175f2a0e199 web/easy_bypass_toggle.js fefafd4550511d80bd85ade46a0476f0cf3de13ddb94a908dff6b175f2a0e199 web/easy_bypass_toggle.js
@@ -429,3 +429,13 @@ d2e59eae0a724626b0a4e361921643dd31cb3612ae1f0d1b8b355c9d42c06174 tests/test_v39
319258798ca198312cf684f369990924657d1af168a148ad34303af31c06a350 tests/test_v39_review_refine_scope.py 319258798ca198312cf684f369990924657d1af168a148ad34303af31c06a350 tests/test_v39_review_refine_scope.py
8d0ccf5711e1be0bf63b4e02fecb0b37cd88979894d27b89337cda4a6d1c4ec5 tests/frontend_issue30_ui.cjs 8d0ccf5711e1be0bf63b4e02fecb0b37cd88979894d27b89337cda4a6d1c4ec5 tests/frontend_issue30_ui.cjs
d6b5b969a0c02f1b282da990db3e503e0768747cfac8a4edd32cf8677550e024 tests/test_issue30_frontend.py d6b5b969a0c02f1b282da990db3e503e0768747cfac8a4edd32cf8677550e024 tests/test_issue30_frontend.py
1bc5274ee15de5e0cee6637bd4712c7915bd5133617486a2d6bfbb1bbbc69539 docs/TEMPORARY_STORAGE_JA.md
660a9df28c7d62ad383cda5514c48c7efcb3576f435af023040116d533a56563 storage_api.py
517662b104ab1507bb927a39f25b8503f092c2ba4c39bc277379ba9d9e31b334 storage_fs.py
daeda14d9f5338835661e6738e074a3897d936cd847fe3e78519efabbcdfd0ef storage_memory.py
53da3ac42f4a66e8adc4560049c7c8e7ada82599be8c61f0573c234342ca36ed storage_settings.py
baa86a523872c9dfbe0123b466535fbf94cf408787a516fb17315064c6acef70 tests/frontend_storage_settings.mjs
1bbc7e5755f71d6fdfddcc6dc8337444febee87cb86773835ca6ac6c79d89357 tests/test_storage_api.py
599c8fac84ae817af33ac7972ca3d53d01d1ac49f36f3d5a374dcd8d6d91d217 tests/test_storage_frontend.py
8a512b3afdf394af043a4d6bd7c4fca0c9326e1207930bf5d96b4d0bd7205b4e tests/test_temporary_storage.py
b1083e90751f7cf115ce973db11bc5331afc2c22289e21c0110e98312057534e web/storage_settings.js
+28
View File
@@ -1,3 +1,31 @@
ComfyUI-H3-Continuum 3.9.3 / 一時ストレージ設定
パッケージmetadata: 3.9.3(2026-10-13)。公開登録は12ノード。
設定 → H3Continuum → Storage → 一時ストレージを管理 から、サーバー側の
保存先を指定できます。FinalizeとDecode Cacheが対象で、空欄なら従来どおり。
現在・以前の保存先、論理ファイル量、空き容量、使用中/削除可能な量を表示し、
未使用ファイルだけを削除できます。参照中の出力・alias、所有者不明、別の生存
プロセスや管理対象外のファイルは保護します。Run/Take・完成動画は対象外です。
別の物理ストレージへ書き込み先を移す機能で、総書き込み量は減りません。
1台のディスク内の別フォルダー/別パーティションでは書き込みを逃がせません。
HDDは遅くなる場合があります。RAMの安全余裕を検査しますが、OOM・ページング・
容量変動や使用中のドライブ切断を完全には防げません。VRAM保存は追加しません。
新規ファイルから切り替え、旧出力は元の場所で保持します。Queue実行中・待機中
の保存・削除は拒否し、マルチユーザー運用では閲覧のみです。指定先の障害時に
元のSSDへ黙って書き戻しません。既存ノードのRAM/Disk選択はそのまま使います。
更新はカスタムノードのみ。ComfyUI再起動とブラウザー強制再読込が必要です。
その後の保存先設定の変更には再起動は不要です。公式Workflowのbytes、公開
Node ID/widget順、Run Storage v3、State/Session、生成契約を維持します。
検証結果と範囲はPACKAGE_VALIDATION.txt、詳細仕様はdocs/TEMPORARY_STORAGE_JA.md
を参照。今回GPU生成は行っていません。GitHub Release/Registry公開は別作業。
======================================================================
履歴:3.9.2の記録(以下の件数・結果は当時のもの)
======================================================================
ComfyUI-H3-Continuum 3.9.2 / Issue #30 Frontend hotfix ComfyUI-H3-Continuum 3.9.2 / Issue #30 Frontend hotfix
パッケージmetadata: 3.9.2(2026-10-13)。公開登録は12ノード。 パッケージmetadata: 3.9.2(2026-10-13)。公開登録は12ノード。
+56
View File
@@ -1,3 +1,59 @@
ComfyUI-H3-Continuum 3.9.3 / temporary storage - 2026-10-13
Package metadata: 3.9.3. Public registration: twelve nodes. Existing V3.9
and separate V3.8X2 workflows remain supported without schema migration.
Scope
- Server-owned scratch path for Finalize and Decode Cache. Blank inherits
existing defaults; selected storage never silently falls back to OS temp.
- Settings panel: locations, logical bytes, free capacity, explicit refresh
and conservative unused-file cleanup. No periodic filesystem polling.
- Protect live Tensor/storage aliases, cache mappings, active processes,
unknown owners, unregistered files and directory/link substitutions.
- Atomic settings/revision checks and queue/operation coordination. New
files use the selected destination; existing outputs retain their paths.
- Manual RAM and Disk-backed preflight; discoverable cgroup memory limits.
Auto's 4 GiB threshold and reserve, dtype and generation contracts remain.
Candidate validation
- Real ComfyUI Core 0.38.0 CPU regression: 1740 passed / 2 skipped /
2 expected failures; zero unexpected failures and CUDA initializations.
Expected failures still track the independent Inspector reconfigure bug.
Skips: Windows private-commit metric and absent historical V3.5 workflow.
- New storage regression gate: 37 cases, including real small Tensor/view
mappings, lost/changed roots, failed writes/deletes, ownerless/link
protection, detached helper leases, abrupt subprocess exit, two-process
settings conflict, HTTP queue/read-only guards, and frontend lifecycle.
- tools/validate.ps1: compileall and Core runtime verification passed using
a CPU-only Python adapter; full pytest was run separately as above.
Native PackedLayout, Fixed 3x5s planning and twelve-node registration pass.
- Actual Core 0.38.0 / frontend 1.53.6 / Chromium 151 smoke passed: real
settings navigation, invalid-path rejection, validation/save/cleanup,
ten modal reopens without polling/duplicate requests, page reload with
persisted settings, native synthetic graph serialization/reload, and
Japanese controls at a narrow viewport. No page errors or prompt submits.
The separate production-JS fixture covers 100 reopen cycles.
- All 25 tracked JSON/ZIP assets, including official workflows, retain
their pre-change bytes. Source and Registry payload hashes are verified.
- Windows-focused storage/file-backed/cache CI is configured; its hosted
result is a separate gate from these local Linux checks. The browser
gate is headless desktop Chromium, not mobile hardware or GPU generation.
Limits and update
No GPU generation, long-form throughput, physical SSD write measurement or
mobile hardware validation was performed for this storage change. Memory
and capacity checks do not reserve resources or prevent all OOM/I/O faults.
External drives must remain connected while outputs refer to them. Unknown
legacy cache files remain protected. Multi-user UI mutations are disabled.
The existing Inspector reconfigure expected failures remain independent.
Update custom nodes, restart ComfyUI normally, then hard-refresh the browser.
Changing the saved scratch setting afterwards requires no restart. Source
publication is separate from a GitHub Release/tag or Registry publication.
======================================================================
Historical 3.9.2 validation (counts and scope below belong to that version)
======================================================================
ComfyUI-H3-Continuum 3.9.2 / Issue #30 frontend hotfix - 2026-10-13 ComfyUI-H3-Continuum 3.9.2 / Issue #30 frontend hotfix - 2026-10-13
Package metadata: 3.9.2. Public registration: twelve nodes. Continue using Package metadata: 3.9.2. Public registration: twelve nodes. Continue using
+7 -1
View File
@@ -2,7 +2,13 @@
Updated: 2026-10-13 (Japan time). Updated: 2026-10-13 (Japan time).
## Package 3.9.2 — Issue #30 frontend hotfix ## Package 3.9.3 — temporary storage settings
The current source adds a server-side scratch folder setting for Finalize and Decode Cache, storage usage/free-space reporting and conservative unused-file cleanup. Manual buffer capacity checks retain the existing Auto policy. Node schemas, official workflow bytes, generation identity and saved Runs/Takes are preserved.
The new setting is available under Settings → H3Continuum → Storage. Validation and platform limitations are recorded in PACKAGE_VALIDATION.txt. Source publication does not imply a new GitHub Release/tag or Registry publication.
## Previous package 3.9.2 — Issue #30 frontend hotfix
This package includes three minimal frontend changes: skip Review snapshots without a comparison baseline, notify connected Samplers once per Reference selection, and skip unchanged node dimensions when resizing. Review baseline monitoring, synchronous Take/Queue checks and generation/storage contracts are retained; package metadata is 3.9.2. This package includes three minimal frontend changes: skip Review snapshots without a comparison baseline, notify connected Samplers once per Reference selection, and skip unchanged node dimensions when resizing. Review baseline monitoring, synchronous Take/Queue checks and generation/storage contracts are retained; package metadata is 3.9.2.
+17 -2
View File
@@ -1,4 +1,19 @@
# ComfyUI-H3-Continuum 3.9.2 — V3.9 # ComfyUI-H3-Continuum 3.9.3 — V3.9
## 3.9.3 — choose temporary storage (2026-10-13)
Choose where Continuum writes its temporary decoded frames and Finalize buffer. Open **Settings → H3Continuum → Storage → Manage temporary storage**. Enter an absolute folder on the **ComfyUI server**, or choose a server storage candidate, then validate and save. Leave it blank to keep the existing locations. No workflow changes are required; continue using the V3.9 nodes and your 3.9.1 / 3.9.2 workflows.
- The selected folder applies to **both Finalize and Decode Cache Helper**. It contains a dedicated `h3-continuum-scratch` directory. Saved Runs/Takes and finished videos keep their existing locations.
- The panel shows current and previous locations, temporary file sizes, free space, and files in use or eligible for deletion. **Delete unused temporary files** protects live outputs, Tensor views, active processes and files whose ownership cannot be verified. Deleting a cache can require decoding and writing it again.
- Save or clean only when the running and pending queues are empty. New files use the new location; existing outputs remain valid at their old locations. A missing selected drive does not silently redirect writes to your original SSD. Shared storage controls are read-only in multi-user mode.
- Mode selection stays in the existing nodes: **Finalize: Auto / RAM / Disk-backed**; **Decode Cache Helper: Auto / RAM / Off**. Auto keeps its conservative 4 GiB final-IMAGE threshold and RAM reserve. Manual RAM now checks available memory before allocation; manual Disk-backed checks free space. These checks cannot guarantee against OOM, changing disk usage or a drive disconnect during execution. No new VRAM storage mode is added.
**Moving storage changes where writes occur, not their total volume.** With only one physical drive, moving to another folder or partition on that drive does not divert its writes. A separate SSD is usually the faster alternative; an HDD can be used but may slow decoding, assembly and saving. If sufficient CPU RAM is available, RAM modes can avoid these scratch writes, but memory pressure can cause paging or OOM. Turning Decode Cache Off does not turn off Finalize's Disk-backed buffer. File-size displays are logical sizes, not physical disk allocation or cumulative SSD writes. Local filesystems are supported; network shares are outside this feature's supported scope.
Update the custom node package, restart ComfyUI to load the backend, and hard-refresh the browser. Later changes to this storage setting take effect without a restart. Blank settings retain the ComfyUI temp directory for Finalize and `H3_DECODE_CACHE_TEMP_DIR` (or OS temp) for Decode Cache. A selected folder takes precedence over that cache environment variable.
The storage changes preserve frame dtype, video/audio assembly and generation identity. Validation and remaining platform limits are recorded in [PACKAGE_VALIDATION.txt](PACKAGE_VALIDATION.txt). Screenshots will be added from the implemented settings screen. GitHub Release/tag and Registry publication are separate from this source update.
## 3.9.2 — Issue #30 frontend hotfix (2026-10-13) ## 3.9.2 — Issue #30 frontend hotfix (2026-10-13)
@@ -89,7 +104,7 @@ The selected V3.9 template has 32 nodes. Image loaders 1–6 are wired to the ne
In the helper, `All chunks` uses connected images throughout; `Per chunk` provides an image-by-chunk table. The template starts in `Per chunk` with all assignments off: after enabling a loader, tick the chunks that should use it. Slot numbers never shift: Image 1 is `@R1` and Image 9 is `@R9`, even when intervening slots are empty. In Sequence Prompt, describe the action for each chunk and use `@R` tags only for active References; their actual `<Picture N>` numbers are resolved per group. Unused tags warn without stopping generation. Start with short chunks and pre-resized images: source images may consume RAM before the Sampler's Reference Image Size setting applies. In the helper, `All chunks` uses connected images throughout; `Per chunk` provides an image-by-chunk table. The template starts in `Per chunk` with all assignments off: after enabling a loader, tick the chunks that should use it. Slot numbers never shift: Image 1 is `@R1` and Image 9 is `@R9`, even when intervening slots are empty. In Sequence Prompt, describe the action for each chunk and use `@R` tags only for active References; their actual `<Picture N>` numbers are resolved per group. Unused tags warn without stopping generation. Start with short chunks and pre-resized images: source images may consume RAM before the Sampler's Reference Image Size setting applies.
V3.9.2 is the current source version on `main`. Download versioned source from [GitHub Releases](https://github.com/ukr8b3g-cmyk/ComfyUI-H3-Continuum/releases); ComfyUI Registry publication is separate. Historical Releases and tags remain available. Configured 1024×1024 Reference-only GPU/API runs succeeded, but the unchanged default template and browser save/reload remain separate acceptance gates. For a reproducible older environment, use the matching historical Release/tag and workflow; the retained V3.8 Sampler on current `main` specifically supports V3.8X2 workflows. V3.9.3 is the current source version on `main`. Download versioned source from [GitHub Releases](https://github.com/ukr8b3g-cmyk/ComfyUI-H3-Continuum/releases); ComfyUI Registry publication is separate. Historical Releases and tags remain available. Configured 1024×1024 Reference-only GPU/API runs succeeded, but the unchanged default template and browser save/reload remain separate acceptance gates. For a reproducible older environment, use the matching historical Release/tag and workflow; the retained V3.8 Sampler on current `main` specifically supports V3.8X2 workflows.
`pyproject.toml` declares ComfyUI `>=0.32.0`; earlier real-generation/GPU validation used ComfyUI `0.34.2`, and the scoped Fixed cache comparison above used `0.38.0`. The minimum declaration does not establish V3.9 runtime acceptance on 0.32.0. The previous Windows CPU run is `1696 passed / 1 skipped / 0 failed`; the earlier separate Linux rerun report records `1534 passed / 3 skipped / 0 failed` and does not include the new cache or external INT tests. Neither replaces browser save/reload or GPU acceptance for the unchanged official template. `pyproject.toml` declares ComfyUI `>=0.32.0`; earlier real-generation/GPU validation used ComfyUI `0.34.2`, and the scoped Fixed cache comparison above used `0.38.0`. The minimum declaration does not establish V3.9 runtime acceptance on 0.32.0. The previous Windows CPU run is `1696 passed / 1 skipped / 0 failed`; the earlier separate Linux rerun report records `1534 passed / 3 skipped / 0 failed` and does not include the new cache or external INT tests. Neither replaces browser save/reload or GPU acceptance for the unchanged official template.
+17 -2
View File
@@ -1,4 +1,19 @@
# ComfyUI-H3-Continuum 3.9.2 — V3.9 # ComfyUI-H3-Continuum 3.9.3 — V3.9
## 3.9.3 — 一時ストレージの保存先設定(2026-10-13)
未圧縮フレームなどの一時データを、指定したストレージへ保存できるようになりました。**設定 → H3Continuum → Storage → 一時ストレージを管理**を開き、**ComfyUIサーバー側**の絶対パスを入力するかストレージ候補を選択して、検証・保存してください。空欄なら従来の保存先を使用します。ワークフローの変更は不要で、V3.9ノードと3.9.1/3.9.2のワークフローを引き続き使用できます。
- **FinalizeとDecode Cache Helperの両方**が対象です。指定先の`h3-continuum-scratch`専用領域へ保存します。Run/Takeや完成動画の保存先は別です。
- 現在・以前の保存先、一時ファイル量、空き容量、使用中/削除可能な容量を表示します。**未使用の一時ファイルを削除**は、参照中の出力・Tensorのview・生存プロセス・所有者不明のファイルを保護します。キャッシュ削除後は再デコード・再書き込みが必要になる場合があります。
- 保存・削除は実行中と待機中のQueueが空のときに行います。新しいファイルから保存先を切り替え、既存出力は元の場所で保持します。指定先が使えない場合、元のSSDへ黙って戻しません。マルチユーザー運用では共有保存先のUIは閲覧のみです。
- 使用方式は既存ノードで選びます。**Finalize:Auto/RAM/Disk-backed、Decode Cache Helper:Auto/RAM/Off**。Autoの4 GiB境界とRAM安全余裕は維持します。手動RAMは確保前に空きメモリを、手動Disk-backedは空き容量を確認します。ただし、実行中のメモリ・容量変動やドライブ切断まで防ぐ保証はありません。VRAMを保存領域にする機能は追加していません。
**保存先変更は書き込み先を変える機能で、総書き込み量を減らすものではありません。** 物理ストレージが1台なら、同じ機器の別フォルダー・別パーティションへ移しても書き込みを逃がせません。別のSSDは速度を保ちやすく、HDDも使用できますがDecode・結合・保存が遅くなる場合があります。十分なCPU RAMがあればRAM方式で一時書き込みを避けられますが、余裕がなければページファイルへの書き込みやOOMが起こり得ます。CacheをOffにするだけではFinalizeのDisk-backedを無効にしません。容量表示は論理ファイルサイズであり、物理占有量やSSDの累計書き込み量ではありません。対応先はローカルファイルシステムで、ネットワーク共有は正式対応外です。
更新時はカスタムノードを更新し、ComfyUIを再起動してブラウザーを強制再読込してください。その後の保存先設定の変更には再起動は不要です。空欄時はFinalizeがComfyUIのtemp、Decode Cacheが既存の`H3_DECODE_CACHE_TEMP_DIR`指定またはOSのtempを使います。フォルダーを指定した場合、その指定がキャッシュ用環境変数より優先します。
映像のdtype、動画・音声の結合計算、生成条件の識別は維持します。[実装仕様](docs/TEMPORARY_STORAGE_JA.md)と[検証記録](PACKAGE_VALIDATION.txt)も参照してください。設定画面のスクリーンショットは、実装後の実画面を受領してから追加します。GitHub Release/tag・Registry公開は今回のソース更新とは別です。
## 3.9.2 — Issue #30 Frontend hotfix(2026-10-13) ## 3.9.2 — Issue #30 Frontend hotfix(2026-10-13)
@@ -89,7 +104,7 @@ ComfyUIの **Templates → ComfyUI-H3-Continuum** には、今回選んだ[V3.9
ヘルパーの `All chunks` は接続画像を全チャンクに、`Per chunk` は画像×チャンクの表で指定します。このテンプレートは`Per chunk`で全チェックOFFから始まるため、Loaderを有効にした後、使用したいチャンクにもチェックしてください。空欄があっても番号はずれず、Image 1は常に`@R1`、Image 9は`@R9`です。Sequence Promptにはチャンクごとの動作を短く書き、そのチャンクで使う画像の`@R`タグを付けます。内部の`<Picture N>`番号はgroupごとに自動変換されます。使わないタグは警告しますが生成を止めません。まず短いチャンクと縮小済み画像で試してください。入力元画像はSamplerのReference Image Size設定より前にRAMを使うことがあります。 ヘルパーの `All chunks` は接続画像を全チャンクに、`Per chunk` は画像×チャンクの表で指定します。このテンプレートは`Per chunk`で全チェックOFFから始まるため、Loaderを有効にした後、使用したいチャンクにもチェックしてください。空欄があっても番号はずれず、Image 1は常に`@R1`、Image 9は`@R9`です。Sequence Promptにはチャンクごとの動作を短く書き、そのチャンクで使う画像の`@R`タグを付けます。内部の`<Picture N>`番号はgroupごとに自動変換されます。使わないタグは警告しますが生成を止めません。まず短いチャンクと縮小済み画像で試してください。入力元画像はSamplerのReference Image Size設定より前にRAMを使うことがあります。
V3.9.2は`main`の現行ソースです。バージョンを固定したソースは[GitHub Releases](https://github.com/ukr8b3g-cmyk/ComfyUI-H3-Continuum/releases)から取得してください。ComfyUI Registryへの公開は別の作業です。過去のReleaseとtagも残します。設定済み1024×1024のReference-only GPU/APIテストは通っていますが、無改変の公式テンプレート初期設定とブラウザー保存・再読込は別の受入項目です。古い環境を厳密に再現するには対応する過去のRelease/tagとWorkflowを使用してください。現行mainにもV3.8 Samplerを残し、V3.8X2 Workflowを使えるようにしています。 V3.9.3は`main`の現行ソースです。バージョンを固定したソースは[GitHub Releases](https://github.com/ukr8b3g-cmyk/ComfyUI-H3-Continuum/releases)から取得してください。ComfyUI Registryへの公開は別の作業です。過去のReleaseとtagも残します。設定済み1024×1024のReference-only GPU/APIテストは通っていますが、無改変の公式テンプレート初期設定とブラウザー保存・再読込は別の受入項目です。古い環境を厳密に再現するには対応する過去のRelease/tagとWorkflowを使用してください。現行mainにもV3.8 Samplerを残し、V3.8X2 Workflowを使えるようにしています。
`pyproject.toml`の宣言上はComfyUI `>=0.32.0`ですが、以前の実生成・GPU検証はComfyUI `0.34.2`、上記の限定したFixedキャッシュ比較は`0.38.0`で行いました。最低宣言版でV3.9の実機動作を確認済みという意味ではありません。以前のWindows CPU試験は`1696 passed / 1 skipped / 0 failed`、以前の別環境Linux再実行報告は`1534 passed / 3 skipped / 0 failed`で、新しいキャッシュ/外部INT試験は含みません。これらは無改変の公式テンプレートの実ブラウザー保存・再読込やGPU受入を代替しません。 `pyproject.toml`の宣言上はComfyUI `>=0.32.0`ですが、以前の実生成・GPU検証はComfyUI `0.34.2`、上記の限定したFixedキャッシュ比較は`0.38.0`で行いました。最低宣言版でV3.9の実機動作を確認済みという意味ではありません。以前のWindows CPU試験は`1696 passed / 1 skipped / 0 failed`、以前の別環境Linux再実行報告は`1534 passed / 3 skipped / 0 failed`で、新しいキャッシュ/外部INT試験は含みません。これらは無改変の公式テンプレートの実ブラウザー保存・再読込やGPU受入を代替しません。
+21 -15
View File
@@ -1,16 +1,16 @@
dca65fb1393e67f59c6f81f9411e3e745eb8f1097e9a2adf7ffc6f4e3901ca9f __init__.py 02ea0951ce2e7ac2d5f3bbf02c596a9f9ea8adcdf2a113dca4c8db3cc19c36b3 __init__.py
54ba2a58388c42063d24335aa2737e86bd4c15fe9632dcc9ffba18c328e04641 .comfyignore cb19f6b668d08217621f92ec2cc890e9ba3fbe205d1212e01e6b2dd31a0992de .comfyignore
3e7a1ec3380be2a222c8a3e9b8a6bb184d3a760478957f48186438f15235bdba branch_provenance.py 3e7a1ec3380be2a222c8a3e9b8a6bb184d3a760478957f48186438f15235bdba branch_provenance.py
2839ac42889341b018bc6013cfe7e5cf4cca81f3b80fae0620ac30612a5918e5 CHANGELOG.md 32353be7af0fe26ff5aa2ffbc9e22823f1360af9213f27d5011208294b053b80 CHANGELOG.md
c1ed3a0342730450958fb62fd21854a876991f3a4aefb24e5383b0c73cd2312d compatibility.py c1ed3a0342730450958fb62fd21854a876991f3a4aefb24e5383b0c73cd2312d compatibility.py
4d62508f900af9f93ec320afb900c27cc9a300d1e0c0a94714258498c5ede5fc conditioning.py 4d62508f900af9f93ec320afb900c27cc9a300d1e0c0a94714258498c5ede5fc conditioning.py
294251c40b1be2e296c5e5f627b68091d087bdb39179e3a0c3cebd2ee8a344f5 constants.py 294251c40b1be2e296c5e5f627b68091d087bdb39179e3a0c3cebd2ee8a344f5 constants.py
cf255b8a635471229aebadc926acfdcacb65963adbcb9e0f9505d04eada2c6b5 continuation.py cf255b8a635471229aebadc926acfdcacb65963adbcb9e0f9505d04eada2c6b5 continuation.py
51f1d211dfc36602a006fe5d14f4ebb08182694ad464aa9176340ff7e2bd1e41 decode_cache/__init__.py 51f1d211dfc36602a006fe5d14f4ebb08182694ad464aa9176340ff7e2bd1e41 decode_cache/__init__.py
647f55a9253976c059502dec13c7f64d7f7df1ecbe619d543c973f92f7f36776 decode_cache/identity.py 647f55a9253976c059502dec13c7f64d7f7df1ecbe619d543c973f92f7f36776 decode_cache/identity.py
5e599feee3199ee5dbe00e9dfb05c159cb6fe4c0c1ab19677971ce6b1cf4e34c decode_cache/nodes.py c2b44e3caed54c894556af547cd800328ed287a8cc90e0b5031f34bd6bd2224b decode_cache/nodes.py
986cc7a3dc153ff1b41c427a86756e505ea6e17d8b065df1ab15b8ff904f090e decode_cache/service.py 986cc7a3dc153ff1b41c427a86756e505ea6e17d8b065df1ab15b8ff904f090e decode_cache/service.py
8b79ad007488a085284c401f8c1bb99ca6ee58cf736ec9c029548220e2d8adb9 decode_cache/store.py 630ba3d2183964444c4341a8df507f7af61dac6a8e5aaca8cf387a5376d49f27 decode_cache/store.py
a4705ae4b5730d2b43e29fe125a64196a031f14bcfa8702663a17aa89f683d89 docs/images/v39/v38x2-feature-summary-historical.png a4705ae4b5730d2b43e29fe125a64196a031f14bcfa8702663a17aa89f683d89 docs/images/v39/v38x2-feature-summary-historical.png
ae3338f720fc22c05ab4a661c68f9c5dcb20d751a835f0e60d4738333be48e63 docs/images/v39/v39-feature-summary.png ae3338f720fc22c05ab4a661c68f9c5dcb20d751a835f0e60d4738333be48e63 docs/images/v39/v39-feature-summary.png
84304d318eea6db3921d366647c6fff9ad488e8c4cfef6ca00988bfd2a6504bc docs/images/v39/v39-reference-images-node.png 84304d318eea6db3921d366647c6fff9ad488e8c4cfef6ca00988bfd2a6504bc docs/images/v39/v39-reference-images-node.png
@@ -42,15 +42,15 @@ bf0556b076dbaca67c3405a7d86c333ca7fdf3d4381529b0a9edc906519943e9 guide_timeline
139546ec1ff459945aa89b50f74b5ee69f62a0e07bbddfcae06936091a409a83 layout_adapter.py 139546ec1ff459945aa89b50f74b5ee69f62a0e07bbddfcae06936091a409a83 layout_adapter.py
c44abbd789091bbead01250dbd5453e60539d2665c69f162335fdbd2936019c2 LICENSE c44abbd789091bbead01250dbd5453e60539d2665c69f162335fdbd2936019c2 LICENSE
d3e213005670e94dee33a240349a4d245cf9a3b6602099f11ed30cf5a32e2c21 media.py d3e213005670e94dee33a240349a4d245cf9a3b6602099f11ed30cf5a32e2c21 media.py
a4b2b73c50ad05e4d6711e5db4a58c12cb98177ced27d29b2fb4e247761c5c01 metadata.ini 34eca7ac7be8c9ab7a67808d7cdb6f2b0ef54ba67d74cad036617a60663cff16 metadata.ini
d7e613e2cc24110213b477bdd1d390234a41f2af3b1ed006a809066d71d658eb model_patch.py d7e613e2cc24110213b477bdd1d390234a41f2af3b1ed006a809066d71d658eb model_patch.py
ecb65a5dbf9e1683c5a3cadd82daaea3a90a2b776f6ebabfbe8b07aa93177422 nodes.py ecb65a5dbf9e1683c5a3cadd82daaea3a90a2b776f6ebabfbe8b07aa93177422 nodes.py
cd187770a30eba87f576da9baa7de8fb53ebfc7e739e8412e1558bf7ed161660 PACKAGE_INFO_JA.txt f67982dd107c1c37c033a860adab343b86390af4ff94bc20f16c836f6dc8915d PACKAGE_INFO_JA.txt
3b729a12c3b89f88055267ef6a14e9df71752fa2d0c4d586d0e8b96a05d3ed7c PACKAGE_VALIDATION.txt e71abe10be665cf58a5f07cd2eea45b3f94ea06443616daadfa2b7c44e3d71de PACKAGE_VALIDATION.txt
b470819f16fc179654dc1600721a63f0a5a14e777f4c004d574b499da6886ba5 public_api.py b470819f16fc179654dc1600721a63f0a5a14e777f4c004d574b499da6886ba5 public_api.py
ffbe4240d104d360c280a5d4743432520c265f1021c5f4668a977b22a6a8bddb pyproject.toml e6190cc7b2ce1adcaa37e221c2edca1f257ca516a80003d6ea87b2e146e028f9 pyproject.toml
65daf6eb0585c4850a0d306a00b801f9f356583f25e23be327f2dc7e98d7cdbd README_JA.md 7b5dde75e41dbc133c6958dcbf54ce381c10e7e1fef253100019bd7e14c7fb47 README_JA.md
9f60c0074efa406611a7433489d87f8b0e7bfbb9e1649b5bf14232ce9dc98641 README.md c1a40d0ed6ffb2cbe893b92677de50e871bcfc8456753656b466540129224174 README.md
9539f5cb9fb695841073fa58d9246d5a7410bc372f6cd340378185004dfaf978 reference_audio.py 9539f5cb9fb695841073fa58d9246d5a7410bc372f6cd340378185004dfaf978 reference_audio.py
5cb9bfd6810d3a93a637451980a4cc5c1436e5b84cfd1c7a111cd192e876351b reference_video.py 5cb9bfd6810d3a93a637451980a4cc5c1436e5b84cfd1c7a111cd192e876351b reference_video.py
caa572ea65dafc86850db99f52433d360ac9c4ab36b854292a3dccd5ba32dc76 reference.py caa572ea65dafc86850db99f52433d360ac9c4ab36b854292a3dccd5ba32dc76 reference.py
@@ -62,7 +62,7 @@ caa572ea65dafc86850db99f52433d360ac9c4ab36b854292a3dccd5ba32dc76 reference.py
0dbe8a5f71c92f3523942343b40787104c8b96781461ba3ba82934a6bdbe5834 THIRD_PARTY_NOTICES.md 0dbe8a5f71c92f3523942343b40787104c8b96781461ba3ba82934a6bdbe5834 THIRD_PARTY_NOTICES.md
f218e1a93c42467c6057c5c1d04d57cc82f6331b97ec9257e4e2dfb9c831876a timeline_video.py f218e1a93c42467c6057c5c1d04d57cc82f6331b97ec9257e4e2dfb9c831876a timeline_video.py
0bc369ee428b8a5bc8e370a81fbab427262a1fdb7805a78c442c91698d65efba tools/__init__.py 0bc369ee428b8a5bc8e370a81fbab427262a1fdb7805a78c442c91698d65efba tools/__init__.py
e5a84569953ee63b9625f4f2e3195ec368204fddcfc746564cfbd0e8449bb8e9 tools/p20_file_backed_tensor_poc.py 2743597d289d9eb12334d1f5cdd630497e237814ddf48b17f6f68da299c01150 tools/p20_file_backed_tensor_poc.py
aab887698f4767722c833b9e55d605f9597ab0d823e32e8c5416f26a210cab1d tools/verify_runtime.py aab887698f4767722c833b9e55d605f9597ab0d823e32e8c5416f26a210cab1d tools/verify_runtime.py
ffd61f3f31c9b6430e1169007ee906c8f5000eba63ee44e2976ad4f5f1112671 v2/__init__.py ffd61f3f31c9b6430e1169007ee906c8f5000eba63ee44e2976ad4f5f1112671 v2/__init__.py
2003902c87bba09cfa143f5a9e4248f3a78c0fb544449a75fd40ba2cacb35655 v2/context_diagnostics.py 2003902c87bba09cfa143f5a9e4248f3a78c0fb544449a75fd40ba2cacb35655 v2/context_diagnostics.py
@@ -81,7 +81,7 @@ be0d8585fa57e0ccd6d02577bbc7299629e5bfe20e186747f571fccc98b67d7e v2/seam_types.
3ea23dbce6fcd217b6e81235855479b9b16fed7a21693cf156f9014555c4fe13 v2/session.py 3ea23dbce6fcd217b6e81235855479b9b16fed7a21693cf156f9014555c4fe13 v2/session.py
78c830cdf49034c6e3b2cd3da5914d5cfc5638eb63ec6dbd1bab13c50d6d4caf v3/__init__.py 78c830cdf49034c6e3b2cd3da5914d5cfc5638eb63ec6dbd1bab13c50d6d4caf v3/__init__.py
ea2922567df90436dd6fa21696833a49dd0cbfeee142a5fedc3a7c303824d473 v3/adaptive_continuity.py ea2922567df90436dd6fa21696833a49dd0cbfeee142a5fedc3a7c303824d473 v3/adaptive_continuity.py
c03f9f6307b5e3a658fe6d94b01b48bbf5726737e1a8979d6d6f374965f2dc50 v3/assembly_v35.py 70bec17d0dce1873b9bb4a51b09daf76833722ce89f005a22b029533a367e62b v3/assembly_v35.py
7815230e0a9540bc2edeaf818e940b7a1fdd817fd217ba8a4f9cb21aaf6a308e v3/assembly.py 7815230e0a9540bc2edeaf818e940b7a1fdd817fd217ba8a4f9cb21aaf6a308e v3/assembly.py
3f62fdb35e804f42d7cbf0828b4e87e69a2b99246c3f7467fe4fa698f1d803c9 v3/conditioning_bridge_nodes.py 3f62fdb35e804f42d7cbf0828b4e87e69a2b99246c3f7467fe4fa698f1d803c9 v3/conditioning_bridge_nodes.py
fa7a355e52fbcfe1f53b16fa1c37af5d839215b49412adb41c90129ae4e9d9f7 v3/driving_nodes.py fa7a355e52fbcfe1f53b16fa1c37af5d839215b49412adb41c90129ae4e9d9f7 v3/driving_nodes.py
@@ -90,7 +90,7 @@ fa7a355e52fbcfe1f53b16fa1c37af5d839215b49412adb41c90129ae4e9d9f7 v3/driving_nod
ac859cb1a6e23b8ceae300d818c24fe1346b649a0d663017a9b3ac64aa96fca3 v3/easy_nodes.py ac859cb1a6e23b8ceae300d818c24fe1346b649a0d663017a9b3ac64aa96fca3 v3/easy_nodes.py
11e9daa45237392ac84ac1b54b3e8d5e980e77102779831824794a2a6675500b v3/easy_video_nodes.py 11e9daa45237392ac84ac1b54b3e8d5e980e77102779831824794a2a6675500b v3/easy_video_nodes.py
fe03ae0aa0dbbbe5f950bb7da34c18a078d841547992c374ea8beda5e3ad4715 v3/execution_planner.py fe03ae0aa0dbbbe5f950bb7da34c18a078d841547992c374ea8beda5e3ad4715 v3/execution_planner.py
6cc7ed74666084c55beb9075304e92a9defafd81b9c6678239ca3859a08cddd7 v3/file_backed_buffer.py 69bf49d0601edbe51730b9d409b1cde647feabde0bde561e416b0b472a27f4e6 v3/file_backed_buffer.py
cb53e1b104415032ec79b7e7aa1c99848e63da3eedaa251eeba102970e4172b5 v3/hires_fix_nodes.py cb53e1b104415032ec79b7e7aa1c99848e63da3eedaa251eeba102970e4172b5 v3/hires_fix_nodes.py
0858487e2b8c0060a856273ffc65d23165b2f253d183f506e27e419aea0da561 v3/latent_resize_nodes.py 0858487e2b8c0060a856273ffc65d23165b2f253d183f506e27e419aea0da561 v3/latent_resize_nodes.py
5b8a54e67a608e757a505abc712effb33312636e3bb235835a485a506e80eeee v3/masked_continuation.py 5b8a54e67a608e757a505abc712effb33312636e3bb235835a485a506e80eeee v3/masked_continuation.py
@@ -128,7 +128,7 @@ d0a004aa3030c8adaa5ea788f9acc758fcb4a556f203f9a3f63fa4e4b5772063 v3/sampling_en
26b13614ba0a5fd8b192a106c9503b2f4b6fe7f9268a0fcb0f544979a49cab34 v3/video_adapter_nodes.py 26b13614ba0a5fd8b192a106c9503b2f4b6fe7f9268a0fcb0f544979a49cab34 v3/video_adapter_nodes.py
4178dcfa442abdb06ce276e05bd7bcbaa6da28469ba5e57d3da3c663de4e4a9d v3/video_seam_v35.py 4178dcfa442abdb06ce276e05bd7bcbaa6da28469ba5e57d3da3c663de4e4a9d v3/video_seam_v35.py
2f07ace1462644f0bee553827b3571535de4d0c2d9ef847bd9e0ca73a4eed5cb v3/video_seam.py 2f07ace1462644f0bee553827b3571535de4d0c2d9ef847bd9e0ca73a4eed5cb v3/video_seam.py
76db0e3f2bba3e72050c6e35c47a1460fc5a74203d82aa63118b3f4e06ae4ac3 version.py 2f677bcbd9a65c7f462e315936bd2de491429a1583475be24a211db768cfc8b8 version.py
b935ad3bb729948bb3890ce967b0ecbef737a5e51ddfc47a0060fc20aa78dcda video_reference_modes.py b935ad3bb729948bb3890ce967b0ecbef737a5e51ddfc47a0060fc20aa78dcda video_reference_modes.py
685df8e0fa23e3663ab31da1e4470cd19bdaa0dc16362cb606e874d9d6153c2c web/decode_cache_helper.js 685df8e0fa23e3663ab31da1e4470cd19bdaa0dc16362cb606e874d9d6153c2c web/decode_cache_helper.js
fefafd4550511d80bd85ade46a0476f0cf3de13ddb94a908dff6b175f2a0e199 web/easy_bypass_toggle.js fefafd4550511d80bd85ade46a0476f0cf3de13ddb94a908dff6b175f2a0e199 web/easy_bypass_toggle.js
@@ -142,3 +142,9 @@ ae59273f163a116ece418957c557c4fd8c3285e3c60814679b9361d2e6e6fa02 web/reference_
beea70f6e25e1366aba5e2689c31733478472f207dc50cad1562cd877152e4f9 web/reference_images_v39.js beea70f6e25e1366aba5e2689c31733478472f207dc50cad1562cd877152e4f9 web/reference_images_v39.js
bf41bf08dd0504eb753fa5781e6c2b8c1285758ad4bb7309975bb9231d5f8e41 web/video_reference_mode_ui.js bf41bf08dd0504eb753fa5781e6c2b8c1285758ad4bb7309975bb9231d5f8e41 web/video_reference_mode_ui.js
7fd122ff08232e114a6ef32171217ea6324e980eb7257d560c466b8177a3d3ec audio_compat.py 7fd122ff08232e114a6ef32171217ea6324e980eb7257d560c466b8177a3d3ec audio_compat.py
1bc5274ee15de5e0cee6637bd4712c7915bd5133617486a2d6bfbb1bbbc69539 docs/TEMPORARY_STORAGE_JA.md
660a9df28c7d62ad383cda5514c48c7efcb3576f435af023040116d533a56563 storage_api.py
517662b104ab1507bb927a39f25b8503f092c2ba4c39bc277379ba9d9e31b334 storage_fs.py
daeda14d9f5338835661e6738e074a3897d936cd847fe3e78519efabbcdfd0ef storage_memory.py
53da3ac42f4a66e8adc4560049c7c8e7ada82599be8c61f0573c234342ca36ed storage_settings.py
b1083e90751f7cf115ce973db11bc5331afc2c22289e21c0110e98312057534e web/storage_settings.js
+7
View File
@@ -1,5 +1,12 @@
# Public development log # Public development log
## 2026-10-13 — package 3.9.3 temporary storage
- Re-review the scratch storage proposal against actual Finalize, Decode Cache and Core settings lifecycles. Implement server-side settings with revision checks, queue coordination, immutable directory identities and no silent disk fallback.
- Add read-only status and explicit cleanup paths. Preserve live aliases and unknown owners; track detached helper disk entries using only metadata and weak leases.
- Add a ComfyUI settings panel without draw-loop scans or periodic polling. Keep existing workflow controls and node registration.
- Add CPU, real HTTP and filesystem regressions plus a Windows-focused CI storage gate. The real-Core CPU candidate passed 1,740 cases with 2 skips and the 2 existing Inspector expected failures, without CUDA initialization. Standard compile/runtime and actual Core/frontend settings save/reload/cleanup checks passed. All 25 JSON/ZIP assets retain their bytes; see PACKAGE_VALIDATION.txt for scope and platform limits.
## 2026-10-13 — Issue #30 frontend hotfix, package 3.9.2 ## 2026-10-13 — Issue #30 frontend hotfix, package 3.9.2
- Limit production changes to baseline-free Review snapshot skipping, one Reference selection notification per connected Sampler, and dimension checks before resizing the Reference helper. Align package metadata and current public guidance with 3.9.2; retain 3.9.1 records as history. - Limit production changes to baseline-free Review snapshot skipping, one Reference selection notification per connected Sampler, and dimension checks before resizing the Reference helper. Align package metadata and current public guidance with 3.9.2; retain 3.9.1 records as history.
+3
View File
@@ -13,6 +13,9 @@ if __package__:
from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
from .temporal import run_temporal_self_test from .temporal import run_temporal_self_test
from .version import PACKAGE_VERSION from .version import PACKAGE_VERSION
from .storage_api import register_routes
register_routes()
try: try:
run_temporal_self_test() run_temporal_self_test()
+1 -1
View File
@@ -85,7 +85,7 @@ class H3DecodeCacheHelper:
def decode(self, cache_mode, ram_budget_mb, disk_budget_gb, reset_token, def decode(self, cache_mode, ram_budget_mb, disk_budget_gb, reset_token,
video_samples=None, video_vae=None, audio_samples=None, audio_vae=None): video_samples=None, video_vae=None, audio_samples=None, audio_vae=None):
with self._lock: with self.service.store.operation(), self._lock:
mode = self._scalar(cache_mode, "cache_mode") mode = self._scalar(cache_mode, "cache_mode")
ram = int(self._scalar(ram_budget_mb, "ram_budget_mb")) ram = int(self._scalar(ram_budget_mb, "ram_budget_mb"))
disk = int(self._scalar(disk_budget_gb, "disk_budget_gb")) disk = int(self._scalar(disk_budget_gb, "disk_budget_gb"))
+130 -2
View File
@@ -10,6 +10,7 @@ import tempfile
import threading import threading
import uuid import uuid
import weakref import weakref
from contextlib import nullcontext
from collections import OrderedDict from collections import OrderedDict
from dataclasses import dataclass, field from dataclasses import dataclass, field
@@ -18,11 +19,20 @@ import torch
from .identity import CacheBypass, tensor_blocks, tensor_digest from .identity import CacheBypass, tensor_blocks, tensor_digest
if "." in __package__:
from .. import storage_settings, storage_fs
from ..storage_memory import system_memory_bytes
else: # The existing standalone cache test/probe entry points remain supported.
storage_settings = storage_fs = None
system_memory_bytes = None
MiB = 1024**2 MiB = 1024**2
GiB = 1024**3 GiB = 1024**3
def available_ram(): def available_ram():
if system_memory_bytes is not None:
return system_memory_bytes()[0] or 0
try: try:
import psutil # already provided by ComfyUI; optional for cache operation import psutil # already provided by ComfyUI; optional for cache operation
return int(psutil.virtual_memory().available) return int(psutil.virtual_memory().available)
@@ -50,14 +60,35 @@ class Entry:
def _cleanup_private_files(state): def _cleanup_private_files(state):
"""Best effort at object/process exit; never close arrays still owned downstream.""" """Best effort at object/process exit; never close arrays still owned downstream."""
with state.get("lock", nullcontext()):
_cleanup_private_files_locked(state)
def _cleanup_private_files_locked(state):
for path, entry in list(state["entries"].items()): for path, entry in list(state["entries"].items()):
if not entry.live(): if not entry.live():
try: try:
if path.parent in state.get("identities", {}):
storage_fs.check_identity(path.parent, state["identities"][path.parent])
path.unlink(missing_ok=True) path.unlink(missing_ok=True)
state["entries"].pop(path, None) state["entries"].pop(path, None)
except OSError: except OSError:
pass pass
if state["root"] is not None: for root, owner in state.get("owners", {}).items():
try:
storage_fs.check_identity(root, owner["identity"])
for name in owner["files"]:
path = root / name
if path not in state["entries"] and storage_fs.regular_file(path):
try:
path.unlink()
except OSError:
pass
except OSError:
pass
for root, expected in state.get("identities", {}).items():
storage_settings.remove_empty_cache_root(root, expected)
if state["root"] is not None and state["root"] not in state.get("identities", {}):
try: try:
state["root"].rmdir() state["root"].rmdir()
except OSError: except OSError:
@@ -78,6 +109,10 @@ class DecodeStore:
self.retired = [] self.retired = []
self.root = None self.root = None
self.temp_parent = temp_parent if temp_parent is not None else (os.environ.get("H3_DECODE_CACHE_TEMP_DIR") or None) self.temp_parent = temp_parent if temp_parent is not None else (os.environ.get("H3_DECODE_CACHE_TEMP_DIR") or None)
self._explicit_parent = temp_parent is not None
self._default_parent = self.temp_parent
self._owners = {}
self._scratch_token = uuid.uuid4().hex
self.memory_probe = memory_probe self.memory_probe = memory_probe
self.disk_probe = disk_probe self.disk_probe = disk_probe
self.headroom_bytes = headroom_bytes self.headroom_bytes = headroom_bytes
@@ -90,9 +125,14 @@ class DecodeStore:
self.max_entries = 256 self.max_entries = 256
# Finalizer state has only paths, disk-entry metadata and weak leases; # Finalizer state has only paths, disk-entry metadata and weak leases;
# no decoded RAM tensor, VAE, store, node, or GPU model is retained. # no decoded RAM tensor, VAE, store, node, or GPU model is retained.
self._cleanup_state = {"root": None, "entries": {}} self._cleanup_state = {"root": None, "entries": {}, "identities": {},
"lock": self._lock, "owners": self._owners}
weakref.finalize(self, _cleanup_private_files, self._cleanup_state) weakref.finalize(self, _cleanup_private_files, self._cleanup_state)
def operation(self):
manager = storage_settings.get_manager() if storage_settings else None
return manager.operation() if manager else nullcontext()
def configure(self, mode, ram_limit, disk_limit, reset_token): def configure(self, mode, ram_limit, disk_limit, reset_token):
with self._lock: with self._lock:
settings = (mode, int(ram_limit), int(disk_limit), int(reset_token)) settings = (mode, int(ram_limit), int(disk_limit), int(reset_token))
@@ -119,6 +159,8 @@ class DecodeStore:
if entry.live(): if entry.live():
return False return False
try: try:
if entry.path.parent in self._owners:
storage_fs.check_identity(entry.path.parent, self._owners[entry.path.parent]["identity"])
entry.path.unlink(missing_ok=True) entry.path.unlink(missing_ok=True)
self._cleanup_state["entries"].pop(entry.path, None) self._cleanup_state["entries"].pop(entry.path, None)
return True return True
@@ -145,6 +187,8 @@ class DecodeStore:
def close(self): def close(self):
self.clear() self.clear()
for root, owner in self._owners.items():
storage_settings.remove_empty_cache_root(root, owner["identity"])
if self.root is not None: if self.root is not None:
try: try:
self.root.rmdir() # only an empty helper-owned directory self.root.rmdir() # only an empty helper-owned directory
@@ -152,9 +196,24 @@ class DecodeStore:
pass pass
def _directory(self): def _directory(self):
manager = storage_settings.get_manager() if storage_settings else None
if manager is not None:
manager.register_store(self)
default = self._default_parent or tempfile.gettempdir()
parent = Path(default).resolve() if self._explicit_parent else manager.resolve("decode", default)
if self.root is not None and self.root.parent != parent:
self.root = None
self.temp_parent = parent
if self.root is None: if self.root is None:
self.root = Path(tempfile.mkdtemp(prefix=f"h3-decode-cache-{os.getpid()}-", dir=self.temp_parent)) self.root = Path(tempfile.mkdtemp(prefix=f"h3-decode-cache-{os.getpid()}-", dir=self.temp_parent))
self._cleanup_state["root"] = self.root self._cleanup_state["root"] = self.root
if manager is not None:
owner = storage_settings.create_cache_owner(self.root)
self._owners[self.root] = owner
self._cleanup_state["identities"][self.root] = owner["identity"]
manager.record_root("decode", self.root.parent)
if self.root in self._owners:
storage_fs.check_identity(self.root, self._owners[self.root]["identity"])
return self.root return self.root
def _ram_room(self, size): def _ram_room(self, size):
@@ -178,6 +237,8 @@ class DecodeStore:
def _read_disk(self, entry): def _read_disk(self, entry):
path = entry.path path = entry.path
if path is not None and path.parent in self._owners:
storage_fs.check_identity(path.parent, self._owners[path.parent]["identity"])
if path is None or path.is_symlink() or path.stat().st_size != entry.file_bytes: if path is None or path.is_symlink() or path.stat().st_size != entry.file_bytes:
raise CacheBypass("disk cache file missing/changed") raise CacheBypass("disk cache file missing/changed")
# Verify the exact serialized payload before exposing a mapping. # Verify the exact serialized payload before exposing a mapping.
@@ -254,6 +315,8 @@ class DecodeStore:
return None return None
root = self._directory() root = self._directory()
filename = uuid.uuid4().hex filename = uuid.uuid4().hex
if root in self._owners:
storage_settings.register_cache_file(root, self._owners[root], filename)
temp = root / (filename + ".tmp") temp = root / (filename + ".tmp")
final = root / (filename + ".npy") final = root / (filename + ".npy")
dtype = {torch.float16: np.dtype("float16"), torch.float32: np.dtype("float32"), dtype = {torch.float16: np.dtype("float16"), torch.float32: np.dtype("float32"),
@@ -292,6 +355,71 @@ class DecodeStore:
with self._lock: with self._lock:
return key in self.entries return key in self.entries
def inspect_scratch(self, *, cleanup=False, parent):
"""Pure status unless explicitly cleaning; preserve aliases and RAM entries."""
with self._lock:
result = {}
removed = {"removed_files": 0, "removed_bytes": 0, "errors": []}
entries = [(key, entry) for key, entry in self.entries.items()]
entries += [(None, entry) for entry in self.retired]
for key, entry in entries:
path = entry.path
if path is None or path.parent.parent != Path(parent):
continue
try:
if path.parent in self._owners:
storage_fs.check_identity(path.parent, self._owners[path.parent]["identity"])
if not path.is_file() or path.is_symlink():
continue
size = path.stat().st_size
live = any(ref() is not None for ref in entry.leases)
if cleanup and not live and self._delete(entry):
if key is not None:
self.entries.pop(key, None)
else:
self.retired = [item for item in self.retired if item is not entry]
removed["removed_files"] += 1
removed["removed_bytes"] += size
else:
result[str(path)] = "in_use" if live else "deletable"
if cleanup and not live:
removed["errors"].append(f"Could not delete {path.name}; file retained")
except OSError as exc:
result[str(path)] = "unknown"
if cleanup:
removed["errors"].append(str(exc))
# An interrupted unpublished write can leave a registered .tmp.
# The store lock proves no writer is active here; the entry ledger
# continues to protect any published mapping, including retired ones.
for root, owner in self._owners.items():
if root.parent != Path(parent):
continue
try:
storage_fs.check_identity(root, owner["identity"])
for name in owner["files"]:
path = root / name
if path in self._cleanup_state["entries"] or not storage_fs.regular_file(path):
continue
size = path.stat().st_size
if cleanup:
try:
path.unlink()
removed["removed_files"] += 1
removed["removed_bytes"] += size
except OSError as exc:
result[str(path)] = "deletable"
removed["errors"].append(str(exc))
else:
result[str(path)] = "deletable"
except OSError:
pass
if cleanup:
for root, owner in self._owners.items():
if root.parent == Path(parent) and root != self.root:
storage_settings.remove_empty_cache_root(root, owner["identity"])
result[f"__removed_{self._scratch_token}"] = removed
return result
def stats(self): def stats(self):
with self._lock: with self._lock:
self._reap() self._reap()
+208
View File
@@ -0,0 +1,208 @@
# H3 Continuum 一時ストレージ設定 — 実装仕様 v1
作成日:2026-10-13
基準:V3.9.2 / `e9b1294ccd08dfce972cd8e5a11703b3f616ee54`
状態:V3.9.3の実装仕様。検証結果とプラットフォーム範囲は`../PACKAGE_VALIDATION.txt`を参照。
## 1. 目的と対象
Photoshopの仮想記憶ディスクに相当する、一時データの保存先指定を追加する。独自の仮想ディスクを作らず、ComfyUIサーバーに接続された別ストレージ上のフォルダーを利用する。
対象は次の二つ。
- FinalizeのDisk-backed IMAGEバッファ。
- Decode Cache Helperのディスクキャッシュ。
Run Storage、採用済みchunk、Take、State/Session、完成動画・音声、他の拡張機能の一時ファイルは対象外。保存先変更で生成条件、解像度、dtype、Sampling/Reference/Reviewの契約を変更しない。
一時データの移動は書き込み先の変更であり、総書き込み量を減らす機能ではない。物理ストレージが1台しかない場合、別フォルダーや別パーティションへ移しても、その機器への書き込みを逃がせない。ただし十分なRAMがある場合のRAM利用や、任意のDecode Cache無効化は別の対策として利用できる。
## 2. 設定画面
ComfyUIの設定に「H3Continuum → Storage → 一時ストレージを管理」を追加する。専用ノードやワークフロー内のパスwidgetは追加しない。
| 項目 | 確定した動作 |
| --- | --- |
| 保存先フォルダー | サーバー側の絶対パスを入力。空欄で既存の保存先を継承 |
| ストレージ候補 | サーバーで認識できるローカルボリューム/マウント先と空き容量を提示。選択すると保存先入力を補助 |
| 検証・保存 | サーバー上でパス、書き込み、mmap、容量取得を検証してから保存 |
| 保存先と使用量 | Finalize、Decode Cacheごとに実際のパスと管理対象ファイル量を表示 |
| 空き容量 | 各保存先のボリュームの現在の空き容量を表示 |
| 使用中/削除可能/判定不能 | 一時ファイルの状態を分けて表示。判定不能なファイルは保護 |
| 旧保存先 | この設定で登録した旧保存先に残る管理対象ファイル量も表示 |
| 更新 | 手動更新。設定画面を開いた時と保存・削除完了時にも更新 |
| 未使用の一時ファイルを削除 | 実行中は無効。サーバー側でも再検査して、安全と確認できた対象だけ削除 |
ブラウザー/モバイル端末のディスクではなく、ComfyUIが実行されているPC・サーバーのストレージを選ぶ。候補一覧が取得できないOSでも絶対パス入力で利用できる。SSD/HDDの種別を推測してラベル付けしない。異なるボリューム表示が異なる物理ディスクを意味するとは限らない。
表示するファイル量は論理ファイルサイズの合計。物理占有量、SSDの累計書き込み量、寿命指標ではないことを明記する。保存先の空き容量はファイルシステムから別途取得する。同じボリュームを使う二つの保存先の空き容量を加算しない。
描画callbackや常時タイマーでディスクを走査しない。画面表示・操作時に管理対象の範囲だけ確認し、ブラウザー側にイベントの重複登録を作らない。
## 3. 保存先の決定と既存動作
### 空欄
完全に既存の保存先を継承する。
- Finalize:ComfyUIのtemp配下の既存専用フォルダー。
- Decode Cache:既存の`H3_DECODE_CACHE_TEMP_DIR`指定があれば継承し、なければOSのtemp。
空欄のまま、二つの保存先を勝手に統一しない。ComfyUI全体のtemp設定やOSの環境変数を書き換えない。
### 指定あり
指定フォルダーの下に専用領域を作る。
```text
指定フォルダー/
h3-continuum-scratch/
finalize/ … 既存の.binと所有者情報を使用
decode/ … helperごとの私有ディレクトリと.npy
```
新しい設定がDecode Cacheの旧環境変数より優先する。内部テスト等が明示的に渡す`backing_root`や`temp_parent`の依存注入は維持する。
v1の対応先はサーバー上のローカルファイルシステム。ネットワーク共有・UNC・リモートマウントは正式対応外とし、明確に識別できる対象は保存時に拒否する。同期ツールや特殊なファイルシステムの適合性は、書き込み・mmapテストだけでは保証しない。RAMディスクは通常のローカル保存先として扱えるが、専用の作成・管理機能は追加しない。
保存時に正規化したパス、ボリューム識別情報、専用領域の識別情報を記録する。各ファイル作成前にも確認し、マウント解除により元のパスが別ボリュームへ変わった場合は利用しない。
## 4. 設定の保存と切替
- サーバー共通の設定としてComfyUIのsystem user領域に保存する。ブラウザーのローカル保存だけでバックエンドを制御しない。
- 設定本体と管理した保存先一覧は私有のJSONとし、atomic writeで更新する。インストール先、ワークフロー、公開READMEには利用者の実パスを保存しない。
- パス変更と保存はQueueが実行中・待機中でない場合に限る。検証と保存を分け、検証だけで有効設定を変えない。
- Finalize/Decodeの処理開始と設定切替・削除を共通の調停機構で制御する。各処理が取得した設定はその処理の終了まで保持する。
- 保存完了後の新規ファイルから新しい保存先を使う。ComfyUI再起動を必須にしない。
- 既存の一時ファイルは移動しない。旧出力のstorage/aliasやcache entryは、元の保存先と寿命管理を保持する。
- Decode Cacheは保存先の切替後、新規entryを新保存先へ作る。切替時に既存の参照中entryを削除しない。旧entryの安全な再利用・退役を維持する。
- 同じ設定ファイルを複数プロセスが変更する場合は、ファイルロックと設定revision照合で上書き競合を検出する。
- v1ではマルチユーザー運用時のUIからの共有保存先変更・削除を無効にする。共有サーバーの保存先は管理者がサーバー設定として管理する。既存のユーザープロファイルを管理者認証とみなさない。
指定先が使えない場合、元のSSD・OS tempへ黙って戻さない。Finalizeでディスクが必要なら明確なエラーにする。Decode Cacheだけが利用できない場合は、既存の方針に合わせてキャッシュをバイパスしてnative Decodeを続け、元の保存先へキャッシュを書かない。中断・native Decodeの例外はバイパスで隠さない。
## 5. RAM/Diskの選択と事前確認
新しい設定画面に別のRAM/Diskモードを作らず、既存ノードの選択を維持する。
| 対象とモード | 確定した動作 |
| --- | --- |
| Finalize / Auto | 既存の4 GiB境界とRAM安全余裕を維持。ディスクを選んだ場合に新保存先を使用 |
| Finalize / RAM | RAMを使用。確保前に安全余裕を検査し、不足・取得不能なら明確なエラー。ディスクへ自動変更しない |
| Finalize / Disk-backed | 指定先を使用。確保前に空き容量を検査し、不足ならエラー。RAMへ自動変更しない |
| Decode Cache / Auto | 既存のディスクキャッシュ方針とquotaを維持し、ファイルの保存先だけ変更 |
| Decode Cache / RAM | 既存のRAM予算・headroom判定を維持。保持できないentryはキャッシュしない。ディスクへ逃がさない |
| Decode Cache / Off | キャッシュ書き込みを行わない。Finalizeの保存方式は独立 |
Finalizeの必要バイト数`M`は、実際の出力shapeの要素数×実際のdtypeのバイト数で算出する。解像度と秒数だけの固定概算で判定しない。
RAM確保直前の判定は、既存のAutoと同じ余裕を基準にする。
```text
R = max(4 GiB, 物理RAM総量の10%)
利用可能RAM >= M + R
```
手動RAMにはAutoの4 GiB上限を適用しない。十分なRAMが確認できれば大きい出力も選択できる。Autoの4 GiB上限を引き上げる機能はv1に含めない。
Disk-backedの確保直前には、既存Autoと同じ`空き容量 >= M + 2 GiB`を確認する。設定保存時の小さなmmapテストは、将来の大容量確保が成功する保証として扱わない。
空き容量の検査は領域の予約ではない。検査後に別プロセスが容量を使う場合や、利用中のドライブが故障・切断する場合のI/O失敗を完全には防げない。メモリマップされた領域のI/O障害はOSによってプロセス終了につながる場合もある。v1で「誤設定やドライブ障害でもクラッシュしない」と保証しない。全領域を先にゼロ書き込みして二重の大量書き込みを発生させる対策は追加しない。
コンテナーのメモリ制限がある場合、ホストの空きRAMだけを根拠にしない。取得できる場合はプロセスに適用される制限と使用量も考慮し、より厳しい利用可能量を採用する。Autoの4 GiB/reserve方針自体は変えず、実効容量の取り方を検証する。
これはFinalizeの追加バッファを確保する前の確認であり、プロセス全体のOOM回避保証ではない。native VAE Decode、Sampling、下流ノードのコピー、並行処理、OSのページファイル利用まで制御しない。VRAMを一時ストレージにする機能は追加せず、GPUメモリ管理も変更しない。
RAM容量が取得不能な場合、Autoは既存どおりDisk-backedへ進む。手動RAMは安全確認不能として停止する。どちらの場合も選択理由と必要量を表示する。
## 6. 未使用ファイルの削除
「未使用」は生成が終わったことではなく、返したTensor/storage/aliasやcache mappingから参照されていないことを意味する。
- ブラウザーから削除パスを受け取らない。サーバーが登録・確認した保存先と、Continuum所有と確認できるファイルだけを対象にする。
- 使用中のFinalize buffer、未公開の作成中buffer、参照中cache、別の生存プロセスのファイルを保護する。
- Finalizeは既存のstorage寿命追跡、root lock、owner PID+process creation timeを再利用する。UI削除では、owner/sidecarが欠損・不正・判定不能なファイルを削除しない。
- Decode Cacheはstore lockの下で未参照のディスクentryを管理表から退役させて削除する。単に.npyをunlinkして管理表を残さない。RAMキャッシュはこのボタンの対象外。
- 参照中entryと削除保留entryはleaseが切れるまで残す。削除のために出力キャッシュを強制解放したり、gcを強制実行したりしない。
- 新しいDecode Cache私有ディレクトリに所有者情報と排他制御を追加する。前回異常終了のファイルは、所有者が終了したと確認できた範囲だけ削除する。
- 所有者情報がない既存のDecode Cacheディレクトリは、現在のstoreで管理しているファイル以外は自動削除しない。ファイル名のprefixだけを根拠にしない。
- シンボリックリンク/junctionによる管理対象外への遷移をたどらない。設定先の解決結果を記録し、削除時に専用領域の同一性を確認する。
- root・store lockと共通調停で作成/読み込み/削除の競合を防ぐ。他プロセスが現在書いている中間ファイルを削除しない。
- 結果は削除数、削除した論理バイト数、使用中・判定不能・削除失敗の残数を報告する。失敗は保留し、使用中ファイルの強制削除へ切り替えない。
管理対象外のファイル、Run/Take、保存動画、他のComfyUI一時データは削除しない。一時領域全体の再帰削除を実装しない。キャッシュを削除すると次の利用時に再デコード・再書き込みが必要になり得ることも説明する。
## 7. 実装するファイルと責務
| ファイル | 具体的な変更 |
| --- | --- |
| `storage_settings.py` | サーバー共通設定、保存先の検証・解決、管理領域の識別、保存先一覧、調停、容量probeを実装。Tensorの強参照を持たない |
| `storage_api.py` | 設定表示・検証・保存・使用量・削除を提供。登録済み管理対象以外を削除しない |
| `web/storage_settings.js` | ComfyUI設定に操作画面を登録。保存先と実際の使用状態、エラー、削除結果を表示 |
| `storage_fs.py` / `storage_memory.py` | privateファイル・所有者・atomic write・プロセス間lock・cgroupを考慮したRAM取得を担当 |
| `__init__.py` | ComfyUI実ランタイム時だけAPIを一度登録。standalone/offline importを壊さない |
| `v3/file_backed_buffer.py` | 保存先resolverを共通設定へ接続。既存の明示`backing_root`、Auto方針と寿命管理を維持。手動RAM/Diskのpreflightを追加 |
| `v3/assembly_v35.py` | 新規出力確保前に保存先・メモリ・ディスクpreflightを呼ぶ。フレームコピー/Seam/音声の計算は変更しない |
| `tools/p20_file_backed_tensor_poc.py` | 読み取り専用の管理状況取得と、UI向け保守的削除経路を追加。alias寿命追跡と既存sidecarの互換性を維持 |
| `decode_cache/store.py` | 保存先切替、所有者記録、weakなstore登録、状態取得と未参照entry削除を実装。既存key・digest・dtype・quotaは維持 |
| `decode_cache/nodes.py` | helper実行開始時に有効な保存先設定を取得し、storeへ適用。入力widget・既定値・登録IDは変更しない |
| `README.md` / `README_JA.md` | 設定手順、1台構成の限界、HDDの速度、RAM・ページファイル、削除の意味を説明 |
| tests / manifest類 | 新しい安全性・互換性の試験を追加。実装時に既存配布manifestを更新・検証 |
APIは`/h3-continuum/storage/`配下とし、`GET status`、`POST validate`、`POST settings`、`POST cleanup`で役割を分ける。UIは設定revisionを指定して保存し、古いrevisionや実行中の保存/削除は競合として拒否する。読み取りのstatusから削除やcache clearを起こさない。
既存のSampling・Run Storage・State/Session・Referenceの処理は変更しない。公式ワークフローJSON/ZIP、ノードID、socket/widget順序、既存のDecode Cache identityは維持する。Experimental 3、Review From Chunkの仕様は本件に含めない。
## 8. READMEへ必ず記載する内容
1. 別の物理ストレージへの移動は書き込み先を変える機能であり、総書き込み量を減らさない。
2. 物理ストレージが1台の場合、保存先変更で別機器へ書き込みを移すことはできない。同じSSDの別パーティションも同様。
3. HDDは使用できるが、Decode・結合・保存の速度が低下する場合がある。
4. RAMは十分な余裕がある場合に限って利用する。事前確認があってもOOMやページファイルへの書き込みを完全には防げない。
5. 一時保存先はComfyUIサーバー側。保存先を変えても旧ファイルは移動しない。
6. 削除は容量の解放であり、既に発生したSSD書き込みを取り消すものではない。キャッシュ削除は次回の再書き込みを増やす場合がある。
7. FinalizeとDecode Cacheは独立したモード。CacheをOffにするだけではFinalizeのDisk-backedを無効にしない。
8. RAMディスクのデータは再起動で失われる。Run/Takeや完成動画を一時領域と混同しない。
9. 現在の設定・直近の実行で選ばれたbackend・管理対象ファイル量を区別する。Autoを常にSSD使用と説明しない。
10. RAM/ディスクの事前検査は安全性を高めるものであり、実行中のメモリ変動、ディスク容量変動・切断による失敗を完全には防がない。
実装前にスクリーンショットを作成しない。実装後、ユーザー提供の実画面をREADMEへ掲載する。
## 9. 検証と完了条件
### CPU/ファイルシステム
- 空欄時のFinalize/Decode Cacheのパスと環境変数優先順位が従来と一致。
- 指定時は両者の新規ファイルが専用領域に入り、旧保存先へ新規書き込みしない。
- 日本語・空白を含むパス、Windowsドライブ、Linuxローカルマウントで動作。
- 書き込み不可、mmap失敗、容量不足、指定ディスク切断、マウント先入れ替わりで明確な結果を返す。
- 切替前の出力、Tensor view/alias、COW cache mappingが切替・削除後も読める。
- 未参照ファイルだけを削除し、Run/Takeと対象外ファイルを保持。
- owner不明、不正sidecar、symlink/junction、PID再利用、別の生存プロセスを保護。
- Queue/Decode/Finalizeの開始と設定変更・削除の競合を実行順を制御して検証。
- 異常終了後の新形式cacheの残骸は安全に回収でき、旧形式の未管理cacheは保護。
- RAM不足・取得不能・コンテナー制限を小型Tensorとprobe差し替えで検証。実機OOMを起こして試験しない。
- Autoの4 GiB境界とreserve、手動RAMの4 GiB超許可、手動Diskの容量検査を検証。
- キャッシュ障害時のnative Decode継続と、Decode例外/中断の伝播を維持。
- 小型入力で、保存先やbuffer backendを変えてもフレーム・音声・dtypeが一致。
### ブラウザーと互換性
- ComfyUI設定で保存・検証・更新・削除ができ、再接続/再読込後も保存先が一致。
- 実行中・Queue待機中の保存と削除はUIだけでなくサーバーでも拒否。
- 設定画面を繰り返し開閉してもlistenerやDOM、描画処理が増殖しない。
- モバイルではサーバー側パスを扱うことが明確。
- マルチユーザーでは設定・削除の変更操作を拒否。
- 既存V3.8X2/V3.9ワークフローを変更せず保存・再読込できる。
- 既存Review/Take/Reference、file-backed、Decode Cacheの回帰試験と標準validationが通過。
- 公式ワークフローのbyte同一性、配布manifestの整合を確認。
CPU・ブラウザー検証で一時保存先機能の受け入れを判断する。実H3の長尺生成速度、映像・音声品質、実SSD書き込み量は別の実機評価であり、GPU未検証を隠して全体保証としない。
## 10. 初回実装へ含めないもの
データの圧縮/半精度化、VRAMを一時ストレージとして使う機能、独自RAMディスク、複数ディスクへの自動分散・自動フォールバック、Auto RAM上限の変更、全フレームを持たないstreaming出力、ネットワーク共有の正式対応、実SSDの寿命推定は初回に含めない。
確定した初回実装は、保存先指定・状態表示・安全な未使用削除と、そのための容量/所有権/手動RAMの事前確認である。パッケージ番号は3.9.3。GitHub Release/tag・Registry公開はソース更新とは別の作業。
+6 -2
View File
@@ -1,8 +1,12 @@
# H3 Continuum 3.9.2 — 検証手順と受入範囲 # H3 Continuum 3.9.3 — 検証手順と受入範囲
現行版はパッケージ3.9.2、公開12ノードです。引き続きV3.9ノードを使用します。 現行版はパッケージ3.9.3、公開12ノードです。引き続きV3.9ノードを使用します。
旧版の検証手順は末尾に履歴として残しています。 旧版の検証手順は末尾に履歴として残しています。
## 3.9.3 一時ストレージ
保存先切替、参照中のTensor/viewと削除、owner不明・別プロセス保護、RAM/ディスク容量確認、実HTTPの設定APIをCPUで検証します。実ブラウザーでは設定画面の保存・再読込・削除・繰り返し開閉と既存Workflowの読込を確認します。検証件数と実行したプラットフォームはPACKAGE_VALIDATION.txtに記録します。実H3の長尺GPU生成・速度・SSD寿命の確認とは区別します。
## CPU・登録確認 ## CPU・登録確認
リポジトリのルートで、ComfyUIに使用しているPythonを指定して実行します。 リポジトリのルートで、ComfyUIに使用しているPythonを指定して実行します。
+1 -1
View File
@@ -1,4 +1,4 @@
[project] [project]
name = H3 Continuum name = H3 Continuum
version = 3.9.2 version = 3.9.3
description = Native MiniMax H3 masked AV continuation, Second Pass, and disk-backed assembly. description = Native MiniMax H3 masked AV continuation, Second Pass, and disk-backed assembly.
+1 -1
View File
@@ -1,6 +1,6 @@
[project] [project]
name = "comfyui-h3-continuum" name = "comfyui-h3-continuum"
version = "3.9.2" version = "3.9.3"
description = "Integrated N-chunk continuation for ComfyUI native MiniMax H3 video and audio" description = "Integrated N-chunk continuation for ComfyUI native MiniMax H3 video and audio"
readme = "README.md" readme = "README.md"
requires-python = ">=3.10" requires-python = ">=3.10"
+97
View File
@@ -0,0 +1,97 @@
"""ComfyUI endpoints for server-owned temporary storage settings."""
from __future__ import annotations
import asyncio
from contextlib import nullcontext
import logging
from pathlib import Path
import sys
import tempfile
import os
from .storage_settings import StorageSettings, StorageError, install_manager
def register_routes(server=None):
if server is None:
module = sys.modules.get("server")
server = getattr(getattr(module, "PromptServer", None), "instance", None)
if server is None or getattr(server, "_h3_storage_registered", False):
return
import folder_paths
from aiohttp import web
from comfy.cli_args import args
system_directory = getattr(folder_paths, "get_system_user_directory", None)
if system_directory:
directory = Path(system_directory("h3_continuum"))
else:
directory = Path(folder_paths.get_user_directory()) / (getattr(folder_paths, "SYSTEM_USER_PREFIX", "__") + "h3_continuum")
def busy():
queue = getattr(server, "prompt_queue", None)
if queue is None:
return True
running, waiting = queue.get_current_queue()
return bool(running or waiting)
manager = StorageSettings(
directory / "temporary-storage.json",
default_finalize=lambda: Path(folder_paths.get_temp_directory()) / "h3-continuum-v35-file-backed",
default_decode=lambda: os.environ.get("H3_DECODE_CACHE_TEMP_DIR") or tempfile.gettempdir(),
busy=busy,
queue_guard=lambda: getattr(getattr(server, "prompt_queue", None), "mutex", nullcontext()),
read_only=bool(getattr(args, "multi_user", False)),
)
async def handle(request, operation):
try:
# Use Core's existing user validation; a profile is not an admin role.
user_manager = getattr(server, "user_manager", None)
if user_manager is not None:
user_manager.get_request_user_id(request)
if operation == "status":
value = await asyncio.to_thread(manager.status)
else:
if request.content_type != "application/json":
return web.json_response({"error": "Use application/json"}, status=415)
body = await request.json()
if not isinstance(body, dict):
raise StorageError("Request must be a JSON object")
allowed = {"validate": {"path"}, "settings": {"path", "revision"}, "cleanup": set()}[operation]
if set(body) - allowed:
raise StorageError("Unexpected storage request fields")
if operation == "validate":
value = await asyncio.to_thread(manager.validate, body.get("path", ""))
elif operation == "settings":
value = await asyncio.to_thread(manager.save, body.get("path", ""), body.get("revision"))
else:
value = await asyncio.to_thread(manager.cleanup)
return web.json_response(value, headers={"Cache-Control": "no-store"})
except KeyError:
return web.json_response({"error": "Unknown user or invalid storage metadata"}, status=403)
except (StorageError, OSError, ValueError) as exc:
return web.json_response({"error": str(exc)}, status=getattr(exc, "status", 400))
except Exception:
logging.getLogger("h3_continuum.storage").exception("Temporary storage request failed")
return web.json_response({"error": "Temporary storage request failed; see server log"}, status=500)
async def status(request):
return await handle(request, "status")
async def validate(request):
return await handle(request, "validate")
async def settings(request):
return await handle(request, "settings")
async def cleanup(request):
return await handle(request, "cleanup")
server.routes.get("/h3-continuum/storage/status")(status)
server.routes.post("/h3-continuum/storage/validate")(validate)
server.routes.post("/h3-continuum/storage/settings")(settings)
server.routes.post("/h3-continuum/storage/cleanup")(cleanup)
server._h3_storage_registered = True
install_manager(manager)
return manager
+129
View File
@@ -0,0 +1,129 @@
"""Small filesystem primitives for Continuum's private scratch storage."""
from __future__ import annotations
from contextlib import contextmanager
import json
import math
import os
from pathlib import Path
import stat
import threading
import uuid
_LOCKS = {}
_LOCKS_GUARD = threading.Lock()
_LOCAL = threading.local()
def identity(path):
path = Path(path)
info = path.stat()
return {"path": str(path.resolve()), "device": info.st_dev, "inode": info.st_ino}
def check_identity(path, expected):
if identity(path) != expected or str(Path(path).absolute()) != expected["path"]:
raise OSError("Scratch directory changed or its storage is no longer mounted")
def regular_file(path):
try:
info = Path(path).lstat()
return stat.S_ISREG(info.st_mode) and not (getattr(info, "st_file_attributes", 0) & 0x400)
except OSError:
return False
def read_json(path):
path = Path(path)
if not regular_file(path) or path.stat().st_size > 1024 * 1024:
raise OSError("Invalid scratch metadata file")
with path.open("r", encoding="utf-8") as handle:
value = json.load(handle)
if not isinstance(value, dict):
raise ValueError("Scratch metadata must be an object")
return value
def atomic_json(path, value):
path = Path(path)
temporary = path.with_name(path.name + "." + uuid.uuid4().hex + ".partial")
try:
with temporary.open("x", encoding="utf-8") as handle:
json.dump(value, handle, ensure_ascii=False, indent=2)
handle.write("\n")
handle.flush()
os.fsync(handle.fileno())
os.replace(temporary, path)
finally:
temporary.unlink(missing_ok=True)
@contextmanager
def file_lock(path):
"""Reentrant thread/process lock. Callers validate the containing directory."""
path = Path(path)
key = str(path.absolute())
with _LOCKS_GUARD:
lock = _LOCKS.setdefault(key, threading.RLock())
with lock:
depths = getattr(_LOCAL, "depths", None)
if depths is None:
depths = _LOCAL.depths = {}
if depths.get(key, 0):
depths[key] += 1
try:
yield
finally:
depths[key] -= 1
return
if path.is_symlink():
raise OSError("Scratch lock must not be a symbolic link")
with path.open("a+b") as handle:
handle.seek(0, os.SEEK_END)
if handle.tell() == 0:
handle.write(b"\0")
handle.flush()
handle.seek(0)
if os.name == "nt":
import msvcrt
msvcrt.locking(handle.fileno(), msvcrt.LK_LOCK, 1)
else:
import fcntl
fcntl.flock(handle.fileno(), fcntl.LOCK_EX)
depths[key] = 1
try:
yield
finally:
depths.pop(key, None)
if os.name == "nt":
handle.seek(0)
msvcrt.locking(handle.fileno(), msvcrt.LK_UNLCK, 1)
else:
fcntl.flock(handle.fileno(), fcntl.LOCK_UN)
def process_owner():
import psutil
return {"pid": os.getpid(), "created": psutil.Process().create_time()}
def owner_alive(owner):
"""Unknown ownership is protected, including missing process counters."""
try:
import psutil
pid, created = owner["pid"], owner["created"]
if (type(pid) is not int or pid <= 0 or type(created) not in (int, float)
or not math.isfinite(created) or created <= 0):
return True
process = psutil.Process(pid)
return process.is_running() and abs(process.create_time() - created) < 0.01
except Exception as exc:
try:
import psutil
if isinstance(exc, psutil.NoSuchProcess):
return False
except ImportError:
pass
return True
+52
View File
@@ -0,0 +1,52 @@
"""Available CPU memory, bounded by applicable Linux cgroup limits when known."""
from pathlib import Path
def _cgroup_limits(proc=Path("/proc/self/cgroup"), mounts=Path("/proc/self/mountinfo")):
groups = []
for line in proc.read_text().splitlines():
_, controllers, relative = line.split(":", 2)
if controllers == "" or "memory" in controllers.split(","):
groups.append((controllers == "", relative))
for line in mounts.read_text().splitlines():
before, after = line.split(" - ", 1)
fields, filesystem = before.split(), after.split()
for v2, relative in groups:
if (v2 and filesystem[0] != "cgroup2") or (not v2 and (filesystem[0] != "cgroup" or "memory" not in filesystem[-1].split(","))):
continue
mount = Path(fields[4].replace("\\040", " "))
root = fields[3]
if root != "/" and (relative == root or relative.startswith(root.rstrip("/") + "/")):
relative = relative[len(root):]
current = mount / relative.lstrip("/")
# A private cgroup namespace can expose its group at the mount root.
if not current.exists():
current = mount
while current == mount or mount in current.parents:
limit_name, used_name = (("memory.max", "memory.current") if v2 else
("memory.limit_in_bytes", "memory.usage_in_bytes"))
try:
limit = int((current / limit_name).read_text().strip())
used = int((current / used_name).read_text().strip())
if 0 < limit < 2**60 and used >= 0:
yield max(0, limit - used), limit
except (OSError, ValueError):
pass
if current == mount:
break
current = current.parent
def system_memory_bytes():
try:
import psutil
counters = psutil.virtual_memory()
available, total = int(counters.available), int(counters.total)
except Exception:
return None, None
try:
for remaining, limit in _cgroup_limits():
available, total = min(available, remaining), min(total, limit)
except (OSError, ValueError):
pass
return available, total
+460
View File
@@ -0,0 +1,460 @@
"""Server-owned scratch settings; never part of a workflow or generation identity."""
from __future__ import annotations
from contextlib import contextmanager, nullcontext
from functools import wraps
import json
import mmap
import os
from pathlib import Path
import re
import shutil
import tempfile
import threading
import time
import uuid
import weakref
from . import storage_fs as fs
from .storage_memory import system_memory_bytes
_MANAGER = None
_CACHE_NAME = re.compile(r"^[0-9a-f]{32}\.(npy|tmp)$")
_REMOTE_FS = {"nfs", "nfs4", "cifs", "smbfs", "smb3", "sshfs", "fuse.sshfs", "9p", "afs", "davfs"}
_OWNER_FILE = ".h3-owner.json"
class StorageError(RuntimeError):
status = 400
class StorageBusy(StorageError):
status = 409
def install_manager(manager):
global _MANAGER
_MANAGER = manager
def get_manager():
return _MANAGER
def storage_operation(function):
@wraps(function)
def wrapped(*args, **kwargs):
manager = get_manager()
with manager.operation() if manager else nullcontext():
return function(*args, **kwargs)
return wrapped
def _anchor(path):
path = Path(path)
while not path.exists() and path != path.parent:
path = path.parent
return path
def volumes():
result = []
try:
import psutil
for part in psutil.disk_partitions(all=False):
if part.fstype.lower() in _REMOTE_FS or not Path(part.mountpoint).is_dir():
continue
try:
result.append({"path": part.mountpoint, "free_bytes": shutil.disk_usage(part.mountpoint).free,
"device": str(Path(part.mountpoint).stat().st_dev)})
except OSError:
pass
except (ImportError, OSError):
pass
return result
def _local_path(value):
if not isinstance(value, str) or len(value) > 4096 or "\0" in value:
raise StorageError("Enter an absolute folder path on the ComfyUI server")
value = value.strip()
if not value:
return None
if value.startswith(("\\\\", "//")):
raise StorageError("Network shares are not supported for scratch storage")
path = Path(value).expanduser()
if not path.is_absolute():
raise StorageError("The scratch folder must be an absolute server path")
path = path.resolve()
if os.name == "nt":
import ctypes
if ctypes.windll.kernel32.GetDriveTypeW(str(path.anchor)) == 4:
raise StorageError("Network drives are not supported for scratch storage")
try:
import psutil
matches = [p for p in psutil.disk_partitions(all=True)
if path == Path(p.mountpoint) or Path(p.mountpoint) in path.parents]
if matches and max(matches, key=lambda p: len(p.mountpoint)).fstype.lower() in _REMOTE_FS:
raise StorageError("Network mounts are not supported for scratch storage")
except ImportError:
pass
return path
def _probe(directory):
descriptor, name = tempfile.mkstemp(prefix=".h3-probe-", dir=directory)
try:
with os.fdopen(descriptor, "w+b") as handle:
handle.truncate(4096)
with mmap.mmap(handle.fileno(), 4096, access=mmap.ACCESS_WRITE) as mapping:
mapping[:4] = b"H3OK"
mapping.flush()
if mapping[:4] != b"H3OK":
raise StorageError("Scratch mmap verification failed")
os.fsync(handle.fileno())
return shutil.disk_usage(directory).free
finally:
Path(name).unlink(missing_ok=True)
def _prepare(value):
parent = _local_path(value)
if parent is None:
return {"path": "", "roots": []}
scratch = parent / "h3-continuum-scratch"
scratch.mkdir(parents=True, exist_ok=True)
if scratch.resolve() != scratch:
raise StorageError("The dedicated scratch directory must not be a link")
marker = scratch / ".h3-scratch.json"
with fs.file_lock(scratch / ".settings.lock"):
if marker.exists():
payload = fs.read_json(marker)
if payload.get("schema") != "h3-scratch-root-v1":
raise StorageError("This scratch directory has unrecognized ownership metadata")
fs.check_identity(scratch, payload["identity"])
else:
if any(p.name != ".settings.lock" for p in scratch.iterdir()):
raise StorageError("Choose an empty scratch folder; existing unknown files are protected")
payload = {"schema": "h3-scratch-root-v1", "id": uuid.uuid4().hex,
"identity": fs.identity(scratch)}
fs.atomic_json(marker, payload)
roots = []
for kind in ("finalize", "decode"):
directory = scratch / kind
directory.mkdir(exist_ok=True)
if directory.resolve() != directory:
raise StorageError("A scratch subdirectory must not be a link")
free = _probe(directory)
roots.append({"kind": kind, "path": str(directory), "identity": fs.identity(directory),
"scratch": str(scratch), "marker": payload["id"], "free_bytes": free})
return {"path": str(parent), "roots": roots}
def _check_root(record):
fs.check_identity(record["path"], record["identity"])
if record.get("scratch"):
marker = fs.read_json(Path(record["scratch"]) / ".h3-scratch.json")
if marker.get("schema") != "h3-scratch-root-v1" or marker.get("id") != record["marker"]:
raise StorageError("Scratch ownership changed")
fs.check_identity(record["scratch"], marker["identity"])
class StorageSettings:
def __init__(self, config_file, *, default_finalize, default_decode,
busy=lambda: False, queue_guard=nullcontext, read_only=False):
self.config_file = Path(config_file)
self.default_finalize = default_finalize
self.default_decode = default_decode
self.busy = busy
self.queue_guard = queue_guard
self.read_only = read_only
self._gate = threading.RLock()
self._active = 0
self._local = threading.local()
self._stores = weakref.WeakSet()
# Disk entries contain only metadata, weak guards/leases, and paths.
# Retain this ledger after a helper is GC'd, without retaining its tensors.
self._cache_states = {}
self._seen = {}
self._last_backend = None
def _read(self):
if not self.config_file.exists():
return {"schema": 1, "revision": 0, "path": "", "roots": []}
value = fs.read_json(self.config_file)
if (value.get("schema") != 1 or type(value.get("revision")) is not int
or value["revision"] < 0 or not isinstance(value.get("path"), str)
or not isinstance(value.get("roots"), list)):
raise StorageError("Invalid scratch settings; restore the server settings file")
return value
def _config(self):
return getattr(self._local, "config", None) or self._read()
@contextmanager
def operation(self):
if getattr(self._local, "config", None) is not None:
yield
return
with self._gate:
self._local.config = self._read()
self._active += 1
try:
yield
finally:
with self._gate:
self._active -= 1
del self._local.config
@contextmanager
def _maintenance(self):
if self.read_only:
error = StorageError("Temporary storage is read-only in multi-user mode")
error.status = 403
raise error
with self._gate, self.queue_guard():
if self._active or self.busy():
raise StorageBusy("Wait until the running and pending queues are empty")
self.config_file.parent.mkdir(parents=True, exist_ok=True)
with fs.file_lock(self.config_file.with_suffix(".lock")):
yield
def validate(self, path):
with self._maintenance():
return _prepare(path)
def save(self, path, revision):
with self._maintenance():
old = self._read()
if type(revision) is not int or revision != old["revision"]:
raise StorageBusy("Settings changed; refresh before saving")
prepared = _prepare(path)
records = {(r["kind"], r["path"]): r for r in self._records(old)}
records.update({(r["kind"], r["path"]): r for r in prepared["roots"]})
value = {"schema": 1, "revision": revision + 1, "path": prepared["path"],
"roots": list(records.values())}
fs.atomic_json(self.config_file, value)
return value
def resolve(self, kind, default, *, verify=True):
config = self._config()
if not config["path"]:
return Path(default).expanduser().resolve()
target = str(Path(config["path"]) / "h3-continuum-scratch" / kind)
record = next((r for r in config["roots"] if r["kind"] == kind and r["path"] == target), None)
if record is None:
raise StorageError("Configured scratch storage has no validated directory")
if verify:
_check_root(record)
return Path(target)
def verify_final_root(self, path):
config = self._config()
if config["path"] and str(path) == str(Path(config["path"]) / "h3-continuum-scratch" / "finalize"):
self.resolve("finalize", path)
def record_root(self, kind, path):
path = Path(path).resolve()
with self._gate:
key = kind, str(path)
if key not in self._seen:
self._seen[key] = {"kind": kind, "path": str(path), "identity": fs.identity(path)}
def register_store(self, store):
with self._gate:
self._stores.add(store)
self._cache_states[store._scratch_token] = store._cleanup_state
def record_backend(self, backend, required_bytes, root=None):
with self._gate:
self._last_backend = {"backend": backend, "image_bytes": required_bytes,
"path": str(root) if root is not None else None, "at": time.time()}
def _records(self, config):
records = {(r["kind"], r["path"]): r for r in config["roots"]}
for kind, default in (("finalize", self.default_finalize()), ("decode", self.default_decode())):
path = Path(default).expanduser().resolve()
key = kind, str(path)
if key not in records:
records[key] = {"kind": kind, "path": str(path),
"identity": fs.identity(path) if path.exists() else None}
for key, record in self._seen.items():
if key not in records or records[key].get("identity") is None:
records[key] = record
return list(records.values())
def _scan(self, cleanup=False):
from .tools.p20_file_backed_tensor_poc import inspect_managed_files
config = self._read()
with self._gate:
records = self._records(config)
stores = list(self._stores)
live_ids = {store._scratch_token for store in stores}
detached = [state for key, state in self._cache_states.items() if key not in live_ids]
results = []
for record in records:
row = {"kind": record["kind"], "path": record["path"], "bytes": 0,
"in_use_bytes": 0, "deletable_bytes": 0, "unknown_bytes": 0,
"files": 0, "removed_files": 0, "removed_bytes": 0, "errors": []}
path = Path(record["path"])
configured = (str(Path(config["path"]) / "h3-continuum-scratch" / record["kind"])
if config["path"] else str(Path(self.default_finalize() if record["kind"] == "finalize"
else self.default_decode()).expanduser().resolve()))
row["current"] = record["path"] == configured
try:
row["free_bytes"] = shutil.disk_usage(_anchor(path)).free
row["device"] = str(_anchor(path).stat().st_dev)
if record.get("identity") is not None:
_check_root(record)
if not path.exists():
row["exists"] = False
results.append(row)
continue
row["exists"] = True
cleanup_this = cleanup and record.get("identity") is not None
if record["kind"] == "finalize":
scanned = inspect_managed_files(path, cleanup=cleanup_this)
else:
scanned = inspect_decode_files(path, stores, detached=detached, cleanup=cleanup_this)
for item in scanned["files"]:
row["files"] += 1
row["bytes"] += item["bytes"]
row[item["state"] + "_bytes"] += item["bytes"]
row.update({k: scanned[k] for k in ("removed_files", "removed_bytes", "errors")})
except Exception as exc:
row["free_bytes"] = None
row["device"] = None
row["errors"].append(str(exc))
results.append(row)
return results
def status(self):
config = self._read()
available, total = system_memory_bytes()
return {"revision": config["revision"], "path": config["path"],
"read_only": self.read_only, "busy": bool(self._active or self.busy()),
"roots": self._scan(), "volumes": volumes(), "last_backend": self._last_backend,
"memory": {"available_bytes": available, "total_bytes": total},
"size_kind": "logical_file_bytes", "at": time.time()}
def cleanup(self):
with self._maintenance():
return {"roots": self._scan(cleanup=True)}
def create_cache_owner(root):
owner = {"schema": "h3-decode-scratch-v1", "owner": fs.process_owner(),
"identity": fs.identity(root), "files": []}
fs.atomic_json(Path(root) / _OWNER_FILE, owner)
return owner
def register_cache_file(root, owner, name):
fs.check_identity(root, owner["identity"])
if not re.fullmatch(r"[0-9a-f]{32}", name):
raise StorageError("Invalid cache file identity")
# Register before writing so an interrupted writer leaves attributable files.
owner["files"] = [name for name in owner["files"] if fs.regular_file(Path(root) / name)]
owner["files"].extend((name + ".tmp", name + ".npy"))
fs.atomic_json(Path(root) / _OWNER_FILE, owner)
def remove_empty_cache_root(root, expected):
root = Path(root)
try:
fs.check_identity(root, expected)
if all(p.name == _OWNER_FILE for p in root.iterdir()):
(root / _OWNER_FILE).unlink(missing_ok=True)
root.rmdir()
except OSError:
pass
def inspect_decode_files(parent, stores, *, detached=(), cleanup=False):
result = {"files": [], "removed_files": 0, "removed_bytes": 0, "errors": []}
managed = {}
for store in stores:
managed.update(store.inspect_scratch(cleanup=cleanup, parent=parent))
for state in detached:
with state["lock"]:
for path, entry in list(state["entries"].items()):
if path.parent.parent != Path(parent):
continue
try:
fs.check_identity(path.parent, state["identities"][path.parent])
if not fs.regular_file(path):
continue
live = any(ref() is not None for ref in entry.leases)
if cleanup and not live:
size = path.stat().st_size
path.unlink()
state["entries"].pop(path, None)
result["removed_files"] += 1
result["removed_bytes"] += size
else:
managed[str(path)] = "in_use" if live else "deletable"
except (OSError, KeyError):
managed[str(path)] = "unknown"
if cleanup:
for root, owner in state.get("owners", {}).items():
if root.parent != Path(parent):
continue
try:
fs.check_identity(root, owner["identity"])
for name in owner["files"]:
path = root / name
if path not in state["entries"] and fs.regular_file(path):
size = path.stat().st_size
path.unlink()
result["removed_files"] += 1
result["removed_bytes"] += size
except OSError as exc:
result["errors"].append(str(exc))
for root, expected in state["identities"].items():
if root.parent == Path(parent):
remove_empty_cache_root(root, expected)
for root in Path(parent).glob("h3-decode-cache-*"):
if root.is_symlink() or root.resolve() != root or not root.is_dir():
continue
known, dead = set(), False
try:
owner = fs.read_json(root / _OWNER_FILE)
if owner.get("schema") != "h3-decode-scratch-v1":
raise ValueError("Unknown cache owner")
fs.check_identity(root, owner["identity"])
known = {n for n in owner["files"] if isinstance(n, str) and _CACHE_NAME.fullmatch(n)}
dead = not fs.owner_alive(owner["owner"])
except (OSError, ValueError, KeyError, TypeError):
pass
try:
children = list(root.iterdir())
except OSError as exc:
result["errors"].append(str(exc))
continue
for path in children:
if not _CACHE_NAME.fullmatch(path.name) or not fs.regular_file(path):
continue
try:
size = path.stat().st_size
state = managed.get(str(path), "deletable" if dead and path.name in known else "unknown")
if path.name in known and not dead and str(path) not in managed:
state = "in_use"
if cleanup and dead and path.name in known:
fs.check_identity(root, owner["identity"])
path.unlink()
result["removed_files"] += 1
result["removed_bytes"] += size
else:
result["files"].append({"bytes": size, "state": state})
except OSError as exc:
result["errors"].append(str(exc))
if cleanup and dead:
remove_empty_cache_root(root, owner["identity"])
# Current stores remove entries under their own locks; count those removals.
for state in managed.values():
if isinstance(state, dict):
result["removed_files"] += state["removed_files"]
result["removed_bytes"] += state["removed_bytes"]
result["errors"].extend(state.get("errors", []))
return result
+90
View File
@@ -0,0 +1,90 @@
import assert from "node:assert/strict";
import fs from "node:fs";
import vm from "node:vm";
class Element extends EventTarget {
constructor(tag) { super(); this.tag = tag; this.children = []; this.style = {}; this.dataset = {}; this.attributes = {}; this.value = ""; this.disabled = false; this.textContent = ""; }
append(child) { child.parentElement = this; this.children.push(child); }
replaceChildren() { for (const child of this.children) child.parentElement = null; this.children = []; }
setAttribute(name, value) { this.attributes[name] = value; }
get isConnected() { return this === document.body || !!this.parentElement?.isConnected; }
closest() { let node = this; while (node) { if (node.tag === "dialog" || node.attributes.role === "dialog") return node; node = node.parentElement; } return null; }
remove() { this.parentElement.children = this.parentElement.children.filter(x => x !== this); this.parentElement = null; }
showModal() { this.open = true; }
close() { this.open = false; this.dispatchEvent(new Event("close")); }
focus() {}
click() { if (!this.disabled) this.dispatchEvent(new Event("click")); }
}
const all = [];
globalThis.document = { createElement: tag => { const e = new Element(tag); all.push(e); return e; }, body: new Element("body") };
Object.defineProperty(globalThis, "navigator", { value: { language: "en" }, configurable: true });
let definition;
globalThis.__app = { ui: { settings: { getSettingValue: () => "en", addSetting: d => { definition = d; } } }, registerExtension: d => d.setup() };
const api = globalThis.__api = new EventTarget();
const requests = [];
let state = { path: "", revision: 0, busy: false, read_only: false, memory: { available_bytes: 8 * 1024 ** 3 }, roots: [], volumes: [], last_backend: null };
api.fetchApi = async (path, options) => {
const action = path.split("/").at(-1);
const body = options.body ? JSON.parse(options.body) : undefined;
requests.push({ action, body });
let value = structuredClone(state), ok = true;
if (action === "settings") { assert.equal(body.revision, state.revision); state = { ...state, path: body.path, revision: state.revision + 1 }; value = state; }
if (action === "validate") {
ok = !body.path || body.path.startsWith("/");
value = ok ? { path: body.path, roots: [{ free_bytes: 10 * 1024 ** 3 }] } : { error: "absolute path required" };
}
if (action === "cleanup") { assert.deepEqual(body, {}); value = { roots: [] }; }
return { ok, status: ok ? 200 : 400, json: async () => value };
};
const source = fs.readFileSync(new URL("../web/storage_settings.js", import.meta.url), "utf8")
.replace('import { app } from "../../scripts/app.js";', "const app = globalThis.__app;")
.replace('import { api } from "../../scripts/api.js";', "const api = globalThis.__api;")
.replace("export function openStorageDialog", "function openStorageDialog");
vm.runInThisContext(source);
const settings = new Element("section"); settings.setAttribute("role", "dialog"); document.body.append(settings);
const row = definition.type(); settings.append(row);
const launch = row.children[0].children[0];
const connected = tag => all.filter(x => x.tag === tag && x.isConnected);
const dialog = () => connected("dialog")[0];
const control = name => all.find(x => x.tag === "button" && x.isConnected && x.textContent === name);
const settle = () => new Promise(resolve => setImmediate(resolve));
launch.click(); await settle();
assert.equal(dialog().parentElement, settings, "preserve Core's settings dialog during native-modal interactions");
assert.equal(connected("input")[0].value, "");
assert.equal(requests.filter(r => r.action === "status").length, 1);
launch.click(); assert.equal(connected("dialog").length, 1, "no duplicate modal");
const input = connected("input")[0];
input.value = "relative"; input.dispatchEvent(new Event("input"));
control("Validate").click(); await settle();
assert.ok(all.some(x => x.isConnected && x.textContent === "absolute path required"));
input.value = "/scratch"; input.dispatchEvent(new Event("input"));
control("Save").click(); control("Save").click(); await settle();
assert.equal(requests.filter(r => r.action === "settings").length, 1, "one save while request is pending");
assert.equal(state.path, "/scratch");
const status = new Event("status"); status.detail = { exec_info: { queue_remaining: 1 } }; api.dispatchEvent(status);
assert.equal(control("Save").disabled, true);
assert.equal(control("Delete unused temporary files").disabled, true);
status.detail.exec_info.queue_remaining = 0; api.dispatchEvent(status);
control("Delete unused temporary files").click(); await settle();
assert.equal(requests.filter(r => r.action === "cleanup").length, 1);
control("Close").click(); assert.equal(connected("dialog").length, 0);
const before = requests.length;
for (let n = 0; n < 100; n++) {
launch.click(); await settle();
assert.equal(connected("input")[0].value, "/scratch");
control("Close").click();
}
await settle();
assert.equal(requests.length - before, 100, "one fetch per open and no periodic polling");
assert.equal(connected("dialog").length, 0);
// A disposed dialog's handler must not receive later status events.
api.dispatchEvent(status);
assert.equal(requests.length - before, 100);
state.read_only = true;
launch.click(); await settle();
assert.equal(control("Save").disabled, true);
assert.equal(control("Delete unused temporary files").disabled, true);
assert.equal(connected("input")[0].disabled, true);
control("Close").click();
console.log("Temporary storage frontend: settings nesting, deduplication, errors, save, busy/read-only gates, cleanup, and 100 reopen cycles passed");
+1 -1
View File
@@ -6,7 +6,7 @@ import tomllib
ROOT = Path(__file__).resolve().parents[1] ROOT = Path(__file__).resolve().parents[1]
EXPECTED_VERSION = "3.9.2" EXPECTED_VERSION = "3.9.3"
def test_v35_release_metadata_is_consistent(): def test_v35_release_metadata_is_consistent():
+80
View File
@@ -0,0 +1,80 @@
"""Real HTTP requests to the production routes, using a model-free server fixture."""
import asyncio
from pathlib import Path
import sys
import threading
from types import SimpleNamespace
import pytest
from aiohttp import web
from aiohttp.test_utils import TestClient, TestServer
from ComfyUI_H3_Continuum_Join import storage_api, storage_settings
@pytest.fixture
def api_server(tmp_path, monkeypatch):
user = tmp_path / "user"
temp = tmp_path / "temp"
temp.mkdir()
def system_user(name):
if not name.replace("_", "").isalnum():
raise ValueError("Invalid system user name")
return str(user / ("__" + name))
monkeypatch.setitem(sys.modules, "folder_paths", SimpleNamespace(
get_system_user_directory=system_user, get_temp_directory=lambda: str(temp)))
monkeypatch.setitem(sys.modules, "comfy.cli_args", SimpleNamespace(args=SimpleNamespace(multi_user=False)))
monkeypatch.setattr(storage_settings, "_MANAGER", None)
queue = SimpleNamespace(mutex=threading.RLock(), running=[], pending=[])
queue.get_current_queue = lambda: (queue.running, queue.pending)
server = SimpleNamespace(routes=web.RouteTableDef(), prompt_queue=queue)
manager = storage_api.register_routes(server)
assert storage_api.register_routes(server) is None
app = web.Application()
app.add_routes(server.routes)
return app, manager, queue
def test_http_validation_save_status_and_revision_conflict(api_server, tmp_path):
app, manager, queue = api_server
async def scenario():
async with TestClient(TestServer(app)) as client:
status = await client.get("/h3-continuum/storage/status")
assert status.status == 200
state = await status.json()
assert state["path"] == "" and not manager.config_file.exists()
destination = str(tmp_path / "scratch disk")
checked = await client.post("/h3-continuum/storage/validate", json={"path": destination})
assert checked.status == 200 and not manager.config_file.exists()
calls = [client.post("/h3-continuum/storage/settings", json={"path": destination, "revision": 0}) for _ in range(2)]
responses = await asyncio.gather(*calls)
assert sorted(r.status for r in responses) == [200, 409]
status = await client.get("/h3-continuum/storage/status")
state = await status.json()
assert state["revision"] == 1 and state["path"] == destination
assert len([r for r in state["roots"] if r["current"]]) == 2
assert (await client.post("/h3-continuum/storage/cleanup", json={})).status == 200
asyncio.run(scenario())
def test_http_rejects_busy_read_only_and_arbitrary_cleanup_paths(api_server, tmp_path):
app, manager, queue = api_server
protected = tmp_path / "accepted.safetensors"
protected.write_bytes(b"keep")
async def scenario():
async with TestClient(TestServer(app)) as client:
prefix = "/h3-continuum/storage/"
assert (await client.post(prefix + "cleanup", json={"path": str(protected)})).status == 400
assert (await client.post(prefix + "cleanup", data="{}")).status == 415
queue.pending.append("queued")
for action, data in (("settings", {"path": "", "revision": 0}), ("cleanup", {}), ("validate", {"path": ""})):
assert (await client.post(prefix + action, json=data)).status == 409
queue.pending.clear()
with manager.operation():
assert (await client.post(prefix + "cleanup", json={})).status == 409
manager.read_only = True
assert (await client.get(prefix + "status")).status == 200
assert (await client.post(prefix + "settings", json={"path": "", "revision": 0})).status == 403
assert (await client.post(prefix + "cleanup", json={})).status == 403
assert protected.read_bytes() == b"keep"
asyncio.run(scenario())
+13
View File
@@ -0,0 +1,13 @@
from pathlib import Path
import shutil
import subprocess
def test_storage_settings_frontend_lifecycle():
node = shutil.which("node")
assert node, "Node.js is required for frontend regression checks"
script = Path(__file__).with_name("frontend_storage_settings.mjs")
result = subprocess.run([node, str(script)], text=True, encoding="utf-8",
capture_output=True, timeout=30)
assert result.returncode == 0, result.stdout + result.stderr
assert "100 reopen cycles passed" in result.stdout
+471
View File
@@ -0,0 +1,471 @@
"""Scratch relocation and cleanup regressions with real small CPU mappings."""
from __future__ import annotations
import gc
import json
import os
import subprocess
import sys
from pathlib import Path
import threading
import weakref
from types import SimpleNamespace
import pytest
import torch
from ComfyUI_H3_Continuum_Join import storage_settings as settings
from ComfyUI_H3_Continuum_Join import storage_fs as fs
from ComfyUI_H3_Continuum_Join import storage_memory as memory
from ComfyUI_H3_Continuum_Join.decode_cache.store import DecodeStore
from ComfyUI_H3_Continuum_Join.decode_cache import store as store_module
from ComfyUI_H3_Continuum_Join.tools import p20_file_backed_tensor_poc as backing
from ComfyUI_H3_Continuum_Join.v3 import file_backed_buffer as buffer
@pytest.fixture
def manager(tmp_path, monkeypatch):
finalize, decode = tmp_path / "default-final", tmp_path / "default-decode"
decode.mkdir()
value = settings.StorageSettings(tmp_path / "user" / "settings.json",
default_finalize=lambda: finalize, default_decode=lambda: decode)
monkeypatch.setattr(settings, "_MANAGER", value)
monkeypatch.setenv("H3_DECODE_CACHE_TEMP_DIR", str(decode))
return value
def cache():
value = DecodeStore(memory_probe=lambda: 10**12, headroom_bytes=0)
value.configure("Auto", 1024**2, 1024**2, 0)
return value
def cache_put(store, name="first"):
x = torch.arange(24, dtype=torch.float32).reshape(2, 3, 4)
result = store.put(name, x, "video", {}, (), store.epoch)
assert result is not None
return result[0]
def total_removed(result):
return sum(row["removed_files"] for row in result["roots"])
def test_default_and_explicit_internal_paths_keep_their_precedence(manager, tmp_path, monkeypatch):
monkeypatch.setattr(buffer.tempfile, "gettempdir", lambda: str(tmp_path))
import sys
monkeypatch.setitem(sys.modules, "folder_paths", SimpleNamespace(get_temp_directory=lambda: str(tmp_path)))
assert buffer.resolve_backing_root() == tmp_path / "h3-continuum-v35-file-backed"
manager.save(str(tmp_path / "日本語 scratch"), 0)
assert buffer.resolve_backing_root() == tmp_path / "日本語 scratch/h3-continuum-scratch/finalize"
assert buffer.resolve_backing_root(tmp_path / "injected") == tmp_path / "injected"
store = cache()
output = cache_put(store)
assert store.root.parent == tmp_path / "日本語 scratch/h3-continuum-scratch/decode"
assert not list(manager.default_decode().iterdir())
del output
store.close()
def test_validation_does_not_activate_a_path_and_settings_survive_reload(manager, tmp_path):
destination = str(tmp_path / "other disk")
manager.validate(destination)
assert manager.status()["path"] == "" and not manager.config_file.exists()
manager.save(destination, 0)
restored = settings.StorageSettings(manager.config_file, default_finalize=manager.default_finalize,
default_decode=manager.default_decode)
assert restored.status()["path"] == destination
with pytest.raises(settings.StorageBusy, match="refresh"):
manager.save("", 0)
manager.save("", 1)
assert manager.status()["path"] == ""
def test_switch_keeps_old_finalize_alias_and_both_cache_mappings(manager, tmp_path):
manager.save(str(tmp_path / "disk-a"), 0)
with buffer.allocate_file_backed_image((2, 3, 4), dtype=torch.float32) as allocation:
allocation.tensor.copy_(torch.arange(24).reshape(2, 3, 4))
output = allocation.publish()
alias = output[1:]
old_final = allocation.record.data_path
del output, allocation
store = cache()
first = cache_put(store)
old_cache = store.entries["first"].path
manager.save(str(tmp_path / "disk-b"), 1)
second = cache_put(store, "second")
assert old_cache.parent != store.entries["second"].path.parent
assert torch.equal(first, second)
result = manager.cleanup()
assert total_removed(result) == 0
assert old_cache.exists() and old_final.exists()
assert alias.sum() == sum(range(12, 24))
del first, second, alias
gc.collect()
result = manager.cleanup()
assert total_removed(result) == 4 # one bin/sidecar pair and two npy files
assert not old_cache.exists() and not old_final.exists()
assert not store.contains("first") and not store.contains("second")
assert cache_put(store, "third").sum() == sum(range(24))
store.close()
def test_status_is_read_only_and_unknown_files_and_runs_are_protected(manager, tmp_path):
manager.save(str(tmp_path / "disk"), 0)
root = buffer.resolve_backing_root()
unknown = root / (backing.FILE_PREFIX + "a" * 32 + ".bin")
unknown.write_bytes(b"orphan")
run = tmp_path / "saved-run.safetensors"
run.write_bytes(b"accepted take")
store = cache()
tensor = cache_put(store)
path = store.entries["first"].path
del tensor
before = {p: p.read_bytes() for p in tmp_path.rglob("*") if p.is_file()}
report = manager.status()
assert any(row["deletable_bytes"] > 0 for row in report["roots"])
assert before == {p: p.read_bytes() for p in tmp_path.rglob("*") if p.is_file()}
assert store.contains("first") and path.exists()
manager.cleanup()
assert unknown.read_bytes() == b"orphan" and run.read_bytes() == b"accepted take"
assert not path.exists()
def test_changed_mount_is_not_recreated_or_replaced_by_default(manager, tmp_path):
manager.save(str(tmp_path / "disk"), 0)
scratch = tmp_path / "disk/h3-continuum-scratch"
scratch.rename(tmp_path / "detached")
with pytest.raises(OSError):
buffer.allocate_file_backed_image((1,), dtype=torch.float32)
store = cache()
with pytest.raises(OSError):
cache_put(store)
assert not scratch.exists()
assert not list(manager.default_decode().iterdir())
@pytest.mark.parametrize("kind", ["finalize", "decode"])
def test_symlink_substitution_protects_the_target(manager, tmp_path, kind):
manager.save(str(tmp_path / "disk"), 0)
target = tmp_path / "disk/h3-continuum-scratch" / kind
moved = tmp_path / "kept"
target.rename(moved)
try:
target.symlink_to(moved, target_is_directory=True)
except OSError:
pytest.skip("OS does not allow creating symbolic links")
report = manager.cleanup()
assert any(row["errors"] for row in report["roots"] if row["kind"] == kind and row["current"])
assert moved.exists()
@pytest.mark.parametrize("read_only,busy", [(True, False), (False, True)])
def test_server_enforces_read_only_and_busy(manager, tmp_path, read_only, busy):
manager.read_only = read_only
manager.busy = lambda: busy
for action in (lambda: manager.validate(str(tmp_path / "disk")),
lambda: manager.save(str(tmp_path / "disk"), 0), manager.cleanup):
with pytest.raises(settings.StorageError):
action()
assert not manager.config_file.exists()
def test_active_operation_blocks_maintenance_and_freezes_configuration(manager, tmp_path):
entered, release = threading.Event(), threading.Event()
errors = []
def work():
try:
with manager.operation():
entered.set()
assert release.wait(3)
except Exception as error:
errors.append(error)
worker = threading.Thread(target=work)
worker.start()
assert entered.wait(3)
try:
with pytest.raises(settings.StorageBusy):
manager.save(str(tmp_path / "disk"), 0)
with pytest.raises(settings.StorageBusy):
manager.cleanup()
finally:
release.set()
worker.join(3)
assert not errors and not worker.is_alive()
manager.save(str(tmp_path / "disk"), 0)
def test_ownerless_legacy_cache_is_never_swept(manager):
root = manager.default_decode() / "h3-decode-cache-old"
root.mkdir()
path = root / ("b" * 32 + ".npy")
path.write_bytes(b"unattributed")
manager.cleanup()
assert path.read_bytes() == b"unattributed"
def test_dead_cache_owner_only_authorizes_registered_files(manager, monkeypatch):
store = cache()
tensor = cache_put(store)
path = store.entries["first"].path
unknown = path.parent / ("c" * 32 + ".npy")
unknown.write_bytes(b"not ours")
second = cache_put(store, "second")
# Isolate the crash-recovery path: the real mapping remains protected until
# released; only then simulate a terminated writer with no live store.
del tensor, second
manager._stores.clear()
manager._cache_states.clear()
monkeypatch.setattr(fs, "owner_alive", lambda owner: False)
result = manager.cleanup()
assert total_removed(result) == 2
assert not path.exists() and unknown.read_bytes() == b"not ours"
def test_deleted_helper_keeps_mapping_until_last_alias_is_released(manager):
store = cache()
output = cache_put(store)
view = output[1:]
path = store.entries["first"].path
ref = weakref.ref(store)
del output, store
gc.collect()
assert ref() is None and path.exists()
assert total_removed(manager.cleanup()) == 0
assert view.sum() == sum(range(12, 24))
del view
gc.collect()
assert total_removed(manager.cleanup()) == 1
assert not path.exists()
@pytest.mark.parametrize("owner", [{}, {"pid": 1, "created": float("nan")}, {"pid": -1, "created": 1}])
def test_unknown_process_ownership_is_protected(owner):
assert fs.owner_alive(owner)
@pytest.mark.parametrize("path", ["relative/folder", "\\\\server\\share", "//server/share", "bad\0path"])
def test_invalid_destinations_do_not_change_settings(manager, path):
with pytest.raises(settings.StorageError):
manager.save(path, 0)
assert manager.status()["path"] == ""
def test_existing_unknown_scratch_folder_is_not_adopted(manager, tmp_path):
root = tmp_path / "disk/h3-continuum-scratch"
root.mkdir(parents=True)
(root / "important").write_text("keep")
with pytest.raises(settings.StorageError, match="unknown"):
manager.save(str(tmp_path / "disk"), 0)
assert (root / "important").read_text() == "keep"
def test_mmap_failure_does_not_activate_destination(manager, tmp_path, monkeypatch):
def fail(*args, **kwargs):
raise OSError("mapping unsupported")
monkeypatch.setattr(settings.mmap, "mmap", fail)
with pytest.raises(OSError):
manager.save(str(tmp_path / "disk"), 0)
assert manager.status()["path"] == ""
assert not list(tmp_path.rglob(".h3-probe-*"))
def test_manual_ram_uses_real_bytes_and_never_falls_back(monkeypatch, tmp_path):
gib = 1024**3
monkeypatch.setattr(buffer, "_system_memory_bytes", lambda: (16*gib, 32*gib))
buffer.preflight_manual_buffer("RAM", 5*gib) # no Auto 4 GiB cap
monkeypatch.setattr(buffer, "_system_memory_bytes", lambda: (6*gib, 32*gib))
with pytest.raises(RuntimeError, match="RAM buffer needs"):
buffer.preflight_manual_buffer("RAM", 3*gib, tmp_path)
assert not list(tmp_path.iterdir())
monkeypatch.setattr(buffer, "_system_memory_bytes", lambda: (None, None))
with pytest.raises(RuntimeError, match="unavailable"):
buffer.preflight_manual_buffer("RAM", 1)
def test_manual_disk_and_auto_disk_shortage_are_explicit(monkeypatch, tmp_path):
monkeypatch.setattr(buffer, "_disk_free_bytes", lambda path: 1024)
with pytest.raises(RuntimeError, match="Disk-backed buffer needs"):
buffer.preflight_manual_buffer("Disk-backed", 1024, tmp_path)
assert not list(tmp_path.iterdir())
def test_cgroup_v2_uses_most_restrictive_ancestor(tmp_path):
mount = tmp_path / "cgroup"
child = mount / "nested"
child.mkdir(parents=True)
(mount / "memory.max").write_text("1000")
(mount / "memory.current").write_text("900")
(child / "memory.max").write_text("500")
(child / "memory.current").write_text("200")
proc = tmp_path / "cgroups"; proc.write_text("0::/nested\n")
mounts = tmp_path / "mounts"; mounts.write_text(f"1 0 0:1 / {mount} rw - cgroup2 cgroup rw\n")
assert list(memory._cgroup_limits(proc, mounts)) == [(300, 500), (100, 1000)]
def test_real_terminated_cache_writer_is_reclaimed(manager, tmp_path):
manager.save(str(tmp_path / "disk"), 0)
repository = Path(__file__).resolve().parents[1]
script = '''
import os,sys,types
from pathlib import Path
import torch
package=types.ModuleType("storage_child")
package.__path__=[sys.argv[1]]
sys.modules[package.__name__]=package
from storage_child import storage_settings as settings
from storage_child.decode_cache.store import DecodeStore
manager=settings.StorageSettings(Path(sys.argv[2]),default_finalize=lambda:Path(sys.argv[3]),default_decode=lambda:Path(sys.argv[3]))
settings.install_manager(manager)
store=DecodeStore(memory_probe=lambda:10**12,headroom_bytes=0)
store.configure("Auto",1024**2,1024**2,0)
output=store.put("entry",torch.ones(2,3,4),"video",{},(),store.epoch)
assert output is not None
os._exit(0)
'''
subprocess.run([sys.executable, "-c", script, str(repository), str(manager.config_file), str(tmp_path)],
check=True, timeout=30)
cache_root = tmp_path / "disk/h3-continuum-scratch/decode"
assert len(list(cache_root.rglob("*.npy"))) == 1
assert total_removed(manager.cleanup()) == 1
assert not list(cache_root.iterdir())
def test_existing_manager_refuses_replaced_root_before_deletion(tmp_path):
root = tmp_path / "original"
manager = backing.StorageLifetimeManager(root)
with manager.allocate((2,), dtype=torch.float32) as allocation:
allocation.tensor.fill_(3)
output = allocation.publish()
record = allocation.record
del allocation, output
moved = tmp_path / "detached"
root.rename(moved)
root.mkdir()
protected = root / record.data_path.name
protected.write_bytes(b"replacement data")
with pytest.raises(backing.FileBackedPoCError, match="changed"):
manager.collect_ready()
assert protected.read_bytes() == b"replacement data"
def test_failed_unpublished_cache_write_remains_cleanable(manager, monkeypatch):
store = cache()
def broken_blocks(tensor):
yield b"partial"
raise OSError("writer interrupted")
original_unlink = Path.unlink
def busy_temp(path, *args, **kwargs):
if path.suffix == ".tmp":
raise PermissionError("temporarily locked")
return original_unlink(path, *args, **kwargs)
with monkeypatch.context() as patch:
patch.setattr(store_module, "tensor_blocks", broken_blocks)
patch.setattr(Path, "unlink", busy_temp)
with pytest.raises(OSError, match="writer interrupted"):
cache_put(store)
assert not store.entries
assert len(list(store.root.glob("*.tmp"))) == 1
assert total_removed(manager.cleanup()) == 1
assert not list(store.root.glob("*.tmp"))
def test_two_processes_cannot_overwrite_the_same_settings_revision(manager, tmp_path):
repository = Path(__file__).resolve().parents[1]
script = '''
import sys,types
from pathlib import Path
package=types.ModuleType("storage_child")
package.__path__=[sys.argv[1]]
sys.modules[package.__name__]=package
from storage_child import storage_settings as settings
manager=settings.StorageSettings(Path(sys.argv[2]),default_finalize=lambda:Path(sys.argv[3]),default_decode=lambda:Path(sys.argv[3]))
sys.stdin.read(1)
try:
manager.save("",0)
print("saved")
except settings.StorageBusy:
print("conflict")
'''
command = [sys.executable, "-c", script, str(repository), str(manager.config_file), str(tmp_path)]
children = [subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, text=True) for _ in range(2)]
try:
for child in children:
child.stdin.write("x"); child.stdin.flush()
outputs = [child.communicate(timeout=15) for child in children]
assert all(child.returncode == 0 for child in children), outputs
assert sorted(out.strip() for out, err in outputs) == ["conflict", "saved"]
assert manager.status()["revision"] == 1
finally:
for child in children:
if child.poll() is None:
child.kill(); child.wait()
def test_cleanup_reports_a_failed_unlink_and_can_retry(manager, monkeypatch):
store = cache()
output = cache_put(store)
path = store.entries["first"].path
del output
original = Path.unlink
def denied(value, *args, **kwargs):
if value == path:
raise PermissionError("file locked")
return original(value, *args, **kwargs)
with monkeypatch.context() as patch:
patch.setattr(Path, "unlink", denied)
result = manager.cleanup()
assert total_removed(result) == 0 and path.exists()
assert any(row["errors"] for row in result["roots"])
assert total_removed(manager.cleanup()) == 1 and not path.exists()
def test_finalize_startup_also_preserves_ownerless_files(manager, tmp_path):
manager.save(str(tmp_path / "disk"), 0)
root = buffer.resolve_backing_root()
orphan = root / (backing.FILE_PREFIX + "d" * 32 + ".bin")
orphan.write_bytes(b"unknown ownership")
with buffer.allocate_file_backed_image((1,), dtype=torch.float32) as allocation:
allocation.tensor.fill_(1)
output = allocation.publish()
assert output.item() == 1
assert orphan.read_bytes() == b"unknown ownership"
@pytest.mark.parametrize("suffix", [".bin", ".json"])
def test_finalize_cleanup_does_not_follow_file_links(manager, tmp_path, monkeypatch, suffix):
manager.save(str(tmp_path / "disk"), 0)
with buffer.allocate_file_backed_image((1,), dtype=torch.float32) as allocation:
output = allocation.publish()
record = allocation.record
del allocation, output
target = record.data_path if suffix == ".bin" else record.metadata_path
outside = tmp_path / ("outside" + suffix)
target.rename(outside)
try:
target.symlink_to(outside)
except OSError:
pytest.skip("File symlinks are unavailable")
before = outside.read_bytes()
assert total_removed(manager.cleanup()) == 0
assert target.is_symlink() and outside.read_bytes() == before
def test_finalize_failed_delete_keeps_ownership_for_retry(manager, tmp_path, monkeypatch):
manager.save(str(tmp_path / "disk"), 0)
with buffer.allocate_file_backed_image((1,), dtype=torch.float32) as allocation:
output = allocation.publish()
record = allocation.record
del allocation, output
original = Path.unlink
def denied(value, *args, **kwargs):
if value == record.data_path:
raise PermissionError("file locked")
return original(value, *args, **kwargs)
with monkeypatch.context() as patch:
patch.setattr(Path, "unlink", denied)
result = manager.cleanup()
assert total_removed(result) == 0 and record.metadata_path.exists()
assert any(row["errors"] for row in result["roots"])
assert total_removed(manager.cleanup()) == 2
+1 -1
View File
@@ -145,4 +145,4 @@ def test_v217_result_pack_expands_legacy_outputs():
def test_v217_has_no_frontend_display_controller(): def test_v217_has_no_frontend_display_controller():
assert not (ROOT / "web" / "h3_continuum_v2.js").exists() assert not (ROOT / "web" / "h3_continuum_v2.js").exists()
version_source = (ROOT / "version.py").read_text(encoding="utf-8") version_source = (ROOT / "version.py").read_text(encoding="utf-8")
assert 'PACKAGE_VERSION = "3.9.2"' in version_source assert 'PACKAGE_VERSION = "3.9.3"' in version_source
+84
View File
@@ -18,6 +18,7 @@ import os
from pathlib import Path from pathlib import Path
import queue import queue
import re import re
import stat
import sys import sys
import threading import threading
import time import time
@@ -257,6 +258,8 @@ def _root_lock(root: Path):
return return
lock_path = root / _LOCK_FILE_NAME lock_path = root / _LOCK_FILE_NAME
if lock_path.is_symlink():
raise FileBackedPoCError("file-backed lock must not be a symbolic link")
try: try:
with lock_path.open("a+b") as handle: with lock_path.open("a+b") as handle:
handle.seek(0, os.SEEK_END) handle.seek(0, os.SEEK_END)
@@ -372,18 +375,26 @@ class StorageLifetimeManager:
): ):
self.root = Path(root).expanduser().resolve() self.root = Path(root).expanduser().resolve()
self.root.mkdir(parents=True, exist_ok=True) self.root.mkdir(parents=True, exist_ok=True)
info = self.root.stat()
self._root_identity = (info.st_dev, info.st_ino)
self._tracked: dict[str, _TrackedStorage] = {} self._tracked: dict[str, _TrackedStorage] = {}
self._pending: dict[str, tuple[Path, ...]] = {} self._pending: dict[str, tuple[Path, ...]] = {}
self._abandoned: queue.SimpleQueue[BackingRecord] = queue.SimpleQueue() self._abandoned: queue.SimpleQueue[BackingRecord] = queue.SimpleQueue()
self._lock = threading.RLock() self._lock = threading.RLock()
self._allocation_hook = allocation_hook self._allocation_hook = allocation_hook
def _check_root_identity(self):
info = self.root.stat()
if self.root.resolve() != self.root or (info.st_dev, info.st_ino) != self._root_identity:
raise FileBackedPoCError("file-backed storage directory changed or was unmounted")
def allocate( def allocate(
self, self,
shape: tuple[int, ...], shape: tuple[int, ...],
*, *,
dtype: torch.dtype = torch.float32, dtype: torch.dtype = torch.float32,
) -> FileBackedAllocation: ) -> FileBackedAllocation:
self._check_root_identity()
with _root_lock(self.root): with _root_lock(self.root):
with self._lock: with self._lock:
self._drain_abandoned_locked() self._drain_abandoned_locked()
@@ -485,6 +496,7 @@ class StorageLifetimeManager:
raise raise
def _register(self, record: BackingRecord, tensor: torch.Tensor) -> None: def _register(self, record: BackingRecord, tensor: torch.Tensor) -> None:
self._check_root_identity()
with _root_lock(self.root): with _root_lock(self.root):
with self._lock: with self._lock:
if record.allocation_id in self._tracked: if record.allocation_id in self._tracked:
@@ -517,6 +529,7 @@ class StorageLifetimeManager:
self._pending[record.allocation_id] = paths self._pending[record.allocation_id] = paths
def collect_ready(self) -> CollectionResult: def collect_ready(self) -> CollectionResult:
self._check_root_identity()
with _root_lock(self.root): with _root_lock(self.root):
with self._lock: with self._lock:
self._drain_abandoned_locked() self._drain_abandoned_locked()
@@ -592,6 +605,77 @@ def get_process_lifetime_manager(
return manager return manager
def inspect_managed_files(root, *, cleanup=False):
"""Inspect known files without GC; UI cleanup protects every unknown owner.
Unlike the standalone recovery probe, leave orphan/partial files alone.
Only a validated pair and an expired tracked storage or a known dead owner
authorize deletion. Never construct a manager just to inspect a directory.
"""
root = Path(root)
result = {"files": [], "removed_files": 0, "removed_bytes": 0, "errors": []}
def regular_known(path):
try:
info = path.lstat()
return (_known_path(root, path) and stat.S_ISREG(info.st_mode)
and not (getattr(info, "st_file_attributes", 0) & 0x400))
except OSError:
return False
if not root.exists() or root.resolve() != root:
return result
key = os.path.normcase(str(root))
with (_root_lock(root) if cleanup else _thread_lock_for_root(root)):
with _PROCESS_MANAGERS_GUARD:
manager = _PROCESS_MANAGERS.get(key)
states = {}
if manager is not None:
with manager._lock:
for allocation_id, tracked in manager._tracked.items():
try:
states[allocation_id] = tracked.expired()
except Exception:
states[allocation_id] = False
seen = set()
for metadata in root.glob(f"{FILE_PREFIX}*.json"):
pair = [metadata.with_suffix(".bin"), metadata]
state = "unknown"
payload = {}
try:
if not regular_known(metadata) or metadata.stat().st_size > 65536:
continue
payload = json.loads(metadata.read_text(encoding="utf-8"))
valid, data = _valid_sidecar(metadata, payload)
if valid and regular_known(data) and data.stat().st_size == payload["nbytes"]:
expired = states.get(payload["allocation_id"])
if expired is True:
state = "deletable"
elif expired is False or _same_live_process(payload["owner_pid"], payload["owner_create_time"]):
state = "in_use"
elif payload["owner_create_time"] is not None:
state = "deletable"
if cleanup and state == "deletable":
for path in pair:
size = path.stat().st_size
if _unlink_known(root, path):
result["removed_files"] += 1
result["removed_bytes"] += size
if manager is not None:
with manager._lock:
manager._tracked.pop(payload["allocation_id"], None)
continue
except (OSError, ValueError, TypeError, AttributeError) as exc:
result["errors"].append(str(exc))
for path in pair:
if path not in seen and regular_known(path):
seen.add(path)
result["files"].append({"bytes": path.stat().st_size, "state": state})
for path in root.glob(f"{FILE_PREFIX}*"):
if path not in seen and regular_known(path):
result["files"].append({"bytes": path.stat().st_size, "state": "unknown"})
return result
def _sidecar_age(metadata_path: Path, payload: dict[str, Any], now: float) -> float: def _sidecar_age(metadata_path: Path, payload: dict[str, Any], now: float) -> float:
created_at = payload.get("created_at") created_at = payload.get("created_at")
if isinstance(created_at, (int, float)) and math.isfinite(float(created_at)): if isinstance(created_at, (int, float)) and math.isfinite(float(created_at)):
+11
View File
@@ -36,7 +36,9 @@ from .file_backed_buffer import (
allocate_file_backed_image, allocate_file_backed_image,
format_auto_buffer_decision, format_auto_buffer_decision,
select_auto_buffer_backend, select_auto_buffer_backend,
preflight_manual_buffer,
) )
from .. import storage_settings
from .plan import FPS, validate_assembly_plan, REVIEW_AUDIO_PROJECTION_KEY from .plan import FPS, validate_assembly_plan, REVIEW_AUDIO_PROJECTION_KEY
@@ -619,6 +621,7 @@ def _assemble_decoded_chunks_v35_core(
resolved_backend = buffer_backend resolved_backend = buffer_backend
resolved_backing_root = backing_root resolved_backing_root = backing_root
auto_decision_report = None auto_decision_report = None
final_image_bytes = math.prod(shape) * first_image.element_size()
if buffer_backend == BUFFER_BACKEND_AUTO: if buffer_backend == BUFFER_BACKEND_AUTO:
final_image_bytes = ( final_image_bytes = (
math.prod(shape) * first_image.element_size() math.prod(shape) * first_image.element_size()
@@ -630,6 +633,8 @@ def _assemble_decoded_chunks_v35_core(
resolved_backend = decision.selected_backend resolved_backend = decision.selected_backend
resolved_backing_root = decision.backing_root resolved_backing_root = decision.backing_root
auto_decision_report = format_auto_buffer_decision(decision) auto_decision_report = format_auto_buffer_decision(decision)
else:
preflight_manual_buffer(buffer_backend, final_image_bytes, backing_root)
allocation: Any allocation: Any
if resolved_backend == BUFFER_BACKEND_RAM: if resolved_backend == BUFFER_BACKEND_RAM:
@@ -641,6 +646,11 @@ def _assemble_decoded_chunks_v35_core(
backing_root=resolved_backing_root, backing_root=resolved_backing_root,
) )
with allocation: with allocation:
settings = storage_settings.get_manager()
if settings is not None:
from .file_backed_buffer import resolve_backing_root
settings.record_backend(resolved_backend, final_image_bytes,
resolve_backing_root(resolved_backing_root) if resolved_backend == BUFFER_BACKEND_DISK else None)
# The file exists at this point, so an ESC received immediately before # The file exists at this point, so an ESC received immediately before
# assembly exercises the same unpublished cleanup path as a mid-copy # assembly exercises the same unpublished cleanup path as a mid-copy
# cancellation. # cancellation.
@@ -675,6 +685,7 @@ def _assemble_decoded_chunks_v35_core(
return result_images, result_audio, report return result_images, result_audio, report
@storage_settings.storage_operation
def assemble_decoded_chunks_v35( def assemble_decoded_chunks_v35(
*, *,
images: list[Any], images: list[Any],
+39 -14
View File
@@ -17,10 +17,13 @@ import threading
import torch import torch
from ..storage_memory import system_memory_bytes
from .. import storage_settings
from ..tools.p20_file_backed_tensor_poc import ( from ..tools.p20_file_backed_tensor_poc import (
FileBackedAllocation, FileBackedAllocation,
StorageLifetimeManager, StorageLifetimeManager,
cleanup_stale_files, inspect_managed_files,
get_process_lifetime_manager, get_process_lifetime_manager,
) )
@@ -65,13 +68,7 @@ class AutoBufferDecision:
def _system_memory_bytes() -> tuple[int | None, int | None]: def _system_memory_bytes() -> tuple[int | None, int | None]:
try: return system_memory_bytes()
import psutil
counters = psutil.virtual_memory()
return int(counters.available), int(counters.total)
except Exception:
return None, None
def _existing_disk_anchor(path: Path) -> Path: def _existing_disk_anchor(path: Path) -> Path:
@@ -84,9 +81,29 @@ def _existing_disk_anchor(path: Path) -> Path:
def _disk_free_bytes(path: Path) -> int: def _disk_free_bytes(path: Path) -> int:
manager = storage_settings.get_manager()
if manager is not None:
manager.verify_final_root(path)
return int(shutil.disk_usage(_existing_disk_anchor(path)).free) return int(shutil.disk_usage(_existing_disk_anchor(path)).free)
def preflight_manual_buffer(backend, final_image_bytes, backing_root=None):
if backend == BUFFER_BACKEND_RAM:
available, total = _system_memory_bytes()
if available is None or total is None:
raise RuntimeError("RAM buffer safety check unavailable; use Auto or Disk-backed, or restore memory counters")
reserve = max(AUTO_RAM_RESERVE_MIN_BYTES, int(total * AUTO_RAM_RESERVE_FRACTION))
if available < final_image_bytes + reserve:
raise RuntimeError(f"RAM buffer needs {final_image_bytes} bytes plus {reserve} bytes reserve; "
f"only {available} bytes are available. Select Auto or Disk-backed.")
elif backend == BUFFER_BACKEND_DISK:
root = resolve_backing_root(backing_root)
free = _disk_free_bytes(root)
if free < final_image_bytes + AUTO_DISK_RESERVE_BYTES:
raise RuntimeError(f"Disk-backed buffer needs {final_image_bytes + AUTO_DISK_RESERVE_BYTES} bytes "
f"including reserve; {free} bytes are free at {root}")
def select_auto_buffer_backend( def select_auto_buffer_backend(
final_image_bytes: int, final_image_bytes: int,
*, *,
@@ -201,7 +218,9 @@ def resolve_backing_root(
if value is None or not str(value).strip(): if value is None or not str(value).strip():
raise RuntimeError("ComfyUI returned an empty temporary directory") raise RuntimeError("ComfyUI returned an empty temporary directory")
base = Path(value) base = Path(value)
return (base.expanduser().resolve() / _BACKING_DIRECTORY_NAME).resolve() default = (base.expanduser().resolve() / _BACKING_DIRECTORY_NAME).resolve()
manager = storage_settings.get_manager()
return manager.resolve("finalize", default, verify=False) if manager else default
def get_file_backed_image_manager( def get_file_backed_image_manager(
@@ -210,15 +229,21 @@ def get_file_backed_image_manager(
"""Return the accepted process-global manager for one resolved root.""" """Return the accepted process-global manager for one resolved root."""
root = resolve_backing_root(backing_root) root = resolve_backing_root(backing_root)
settings = storage_settings.get_manager()
if settings is not None:
settings.verify_final_root(root)
key = os.path.normcase(str(root)) key = os.path.normcase(str(root))
with _CLEANED_ROOTS_LOCK: with _CLEANED_ROOTS_LOCK:
if key not in _CLEANED_ROOTS: if key not in _CLEANED_ROOTS:
# The P2-0 root lock prevents cleanup from observing an allocation # Production startup and the UI share conservative ownership rules.
# between its data-file and sidecar publication. A live owner is # The standalone recovery probe can still inspect legacy orphans;
# always retained; only prior abnormal-exit artifacts are removed. # an unknown production file is never deleted by its name alone.
cleanup_stale_files(root, grace_seconds=0.0) inspect_managed_files(root, cleanup=True)
_CLEANED_ROOTS.add(key) _CLEANED_ROOTS.add(key)
return get_process_lifetime_manager(root) manager = get_process_lifetime_manager(root)
if settings is not None:
settings.record_root("finalize", root)
return manager
def allocate_file_backed_image( def allocate_file_backed_image(
+1 -1
View File
@@ -1,6 +1,6 @@
"""Package version and public schema identifiers.""" """Package version and public schema identifiers."""
PACKAGE_VERSION = "3.9.2" PACKAGE_VERSION = "3.9.3"
STATE_SCHEMA_VERSION = 1 STATE_SCHEMA_VERSION = 1
PLAN_SCHEMA_VERSION = 1 PLAN_SCHEMA_VERSION = 1
PUBLIC_API_VERSION = 3 PUBLIC_API_VERSION = 3
+198
View File
@@ -0,0 +1,198 @@
import { app } from "../../scripts/app.js";
import { api } from "../../scripts/api.js";
const words = {
en: {
title: "H3 Continuum — Temporary Storage", open: "Manage temporary storage", close: "Close",
path: "Scratch folder on the ComfyUI server", default: "Blank: keep existing temporary folders",
volumes: "Choose a server storage location…", validate: "Validate", save: "Save", refresh: "Refresh",
cleanup: "Delete unused temporary files", free: "Free", total: "Temporary files", in_use: "In use",
deletable: "Deletable", unknown: "Protected / unknown", current: "Current", previous: "Previous",
loading: "Loading…", saved: "Saved. New files will use this location; existing files stay where they are.",
valid: "The selected folder passed the write and memory-map checks.", removed: "Deleted",
files: "files", busy: "Wait until the running and pending queues are empty to change or clean storage.",
readonly: "Shared storage is read-only in multi-user mode. The server operator manages this setting.",
note: "This is the server's storage, not the browser device. File sizes are logical sizes, not SSD write totals. Moving to another folder on the same physical disk does not reduce its writes.",
modes: "Keep choosing Auto / RAM / Disk-backed in Finalize, and Auto / RAM / Off in Decode Cache Helper. They are independent. Deleting a cache can require decoding and writing it again.",
memory: "Available CPU RAM", last: "Last Finalize allocation", never: "No Finalize allocation in this process yet",
},
ja: {
title: "H3 Continuum — 一時ストレージ", open: "一時ストレージを管理", close: "閉じる",
path: "ComfyUIサーバー側の一時保存先フォルダー", default: "空欄:従来の一時保存先を使用",
volumes: "サーバーのストレージ候補を選択…", validate: "検証", save: "保存", refresh: "更新",
cleanup: "未使用の一時ファイルを削除", free: "空き容量", total: "一時ファイル量", in_use: "使用中",
deletable: "削除可能", unknown: "保護中/判定不能", current: "現在", previous: "以前",
loading: "読み込み中…", saved: "保存しました。新規ファイルから適用し、既存ファイルは元の場所で保持します。",
valid: "指定先の書き込みとメモリマップの検証に成功しました。", removed: "削除済み",
files: "ファイル", busy: "保存先の変更・削除は、実行中と待機中のQueueが空になるまでお待ちください。",
readonly: "マルチユーザー運用では閲覧のみです。共有保存先はサーバー管理者が管理します。",
note: "対象はブラウザー端末ではなくComfyUIサーバーです。表示容量はファイルの論理サイズで、SSDの累計書き込み量ではありません。同じ物理ディスク内の移動では、そのディスクへの書き込みは減りません。",
modes: "使用方式は従来どおりFinalizeのAuto/RAM/Disk-backedと、Decode Cache HelperのAuto/RAM/Offで選びます。両者は独立しています。キャッシュ削除後は再デコード・再書き込みが必要になる場合があります。",
memory: "利用可能なCPU RAM", last: "直近のFinalize確保", never: "このプロセスではまだFinalizeを実行していません",
},
};
function language() {
const locale = app.ui?.settings?.getSettingValue?.("Comfy.Locale") || navigator.language || "en";
return String(locale).startsWith("ja") ? words.ja : words.en;
}
function size(bytes) {
if (!Number.isFinite(bytes)) return "—";
if (bytes < 1024) return `${bytes} B`;
if (bytes < 1024 ** 2) return `${(bytes / 1024).toFixed(2)} KiB`;
if (bytes < 1024 ** 3) return `${(bytes / 1024 ** 2).toFixed(2)} MiB`;
return `${(bytes / 1024 ** 3).toFixed(2)} GiB`;
}
function element(tag, text, parent) {
const result = document.createElement(tag);
if (text != null) result.textContent = text;
parent?.append(result);
return result;
}
async function request(operation, body) {
const response = await api.fetchApi(`/h3-continuum/storage/${operation}`, body === undefined
? { cache: "no-store" }
: { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
const value = await response.json();
if (!response.ok) throw new Error(value.error || `HTTP ${response.status}`);
return value;
}
let opened = null;
export function openStorageDialog(event) {
if (opened?.isConnected && opened.open) { opened.focus(); return; }
const t = language();
const dialog = element("dialog");
opened = dialog;
dialog.dataset.h3Storage = "true";
dialog.setAttribute("aria-label", t.title);
Object.assign(dialog.style, {
width: "min(760px, 92vw)", maxHeight: "88vh", overflow: "auto", padding: "20px",
background: "var(--comfy-menu-bg, #222)", color: "var(--fg-color, #ddd)",
border: "1px solid var(--border-color, #666)", borderRadius: "10px",
});
const abort = new AbortController();
element("h2", t.title, dialog);
element("p", t.note, dialog);
const label = element("label", t.path, dialog);
const input = element("input", null, label);
input.type = "text"; input.placeholder = t.default; input.setAttribute("aria-label", t.path);
Object.assign(input.style, { display: "block", width: "100%", margin: "8px 0", padding: "8px", boxSizing: "border-box" });
const select = element("select", null, dialog);
select.setAttribute("aria-label", t.volumes); select.style.maxWidth = "100%";
const actions = element("div", null, dialog);
Object.assign(actions.style, { display: "flex", gap: "8px", flexWrap: "wrap", margin: "12px 0" });
const buttons = {};
for (const action of ["validate", "save", "refresh", "cleanup", "close"]) {
const button = element("button", t[action], actions);
button.type = "button"; button.style.padding = "6px 10px"; buttons[action] = button;
}
const notice = element("p", null, dialog);
const message = element("p", t.loading, dialog); message.setAttribute("role", "status");
const memory = element("p", null, dialog);
const last = element("p", null, dialog);
const roots = element("div", null, dialog);
element("p", t.modes, dialog);
let state = null, pending = true, dirty = false, closed = false;
function controls() {
for (const name of ["validate", "save", "cleanup"]) buttons[name].disabled = pending || !state || state.busy || state.read_only;
buttons.refresh.disabled = pending;
input.disabled = pending || !!state?.read_only;
select.disabled = input.disabled;
notice.textContent = state?.read_only ? t.readonly : state?.busy ? t.busy : "";
}
function render(value) {
state = value;
if (!dirty) input.value = value.path;
select.replaceChildren();
const option = element("option", t.volumes, select); option.value = "";
for (const volume of value.volumes) {
const option = element("option", `${volume.path} (${t.free}: ${size(volume.free_bytes)})`, select);
option.value = volume.path;
}
memory.textContent = `${t.memory}: ${size(value.memory.available_bytes)}`;
last.textContent = value.last_backend
? `${t.last}: ${value.last_backend.backend}, ${size(value.last_backend.image_bytes)}${value.last_backend.path ? ` — ${value.last_backend.path}` : ""}`
: t.never;
roots.replaceChildren();
for (const root of value.roots) {
const section = element("section", null, roots);
Object.assign(section.style, { borderTop: "1px solid #666", padding: "10px 0", overflowWrap: "anywhere" });
element("strong", `${root.kind === "finalize" ? "Finalize" : "Decode Cache"} — ${root.current ? t.current : t.previous}`, section);
element("div", root.path, section);
element("div", `${t.total}: ${size(root.bytes)} · ${t.free}: ${size(root.free_bytes)}`, section);
element("div", `${t.in_use}: ${size(root.in_use_bytes)} · ${t.deletable}: ${size(root.deletable_bytes)} · ${t.unknown}: ${size(root.unknown_bytes)}`, section);
for (const error of root.errors) element("p", error, section);
}
}
async function refresh() {
const value = await request("status");
if (!closed) render(value);
}
async function perform(action) {
if (pending) return;
pending = true; controls(); message.textContent = t.loading;
try {
if (action === "refresh") { await refresh(); message.textContent = ""; }
if (action === "validate") {
const result = await request("validate", { path: input.value });
message.textContent = result.path
? `${t.valid} ${result.path} (${t.free}: ${size(result.roots[0]?.free_bytes)})`
: t.default;
}
if (action === "save") {
await request("settings", { path: input.value, revision: state.revision });
dirty = false; await refresh(); message.textContent = t.saved;
}
if (action === "cleanup") {
const result = await request("cleanup", {});
const files = result.roots.reduce((sum, root) => sum + root.removed_files, 0);
const bytes = result.roots.reduce((sum, root) => sum + root.removed_bytes, 0);
const errors = result.roots.flatMap(root => root.errors);
await refresh(); message.textContent = `${t.removed}: ${files} ${t.files}, ${size(bytes)}${errors.length ? ` — ${errors.join("; ")}` : ""}`;
}
} catch (error) { if (!closed) message.textContent = error.message; }
finally { pending = false; if (!closed) controls(); }
}
input.addEventListener("input", () => { dirty = true; });
select.addEventListener("change", () => { if (select.value) { input.value = select.value; dirty = true; } });
for (const name of ["validate", "save", "refresh", "cleanup"]) buttons[name].addEventListener("click", () => perform(name));
buttons.close.addEventListener("click", () => dialog.close());
dialog.addEventListener("close", () => { closed = true; abort.abort(); dialog.remove(); if (opened === dialog) opened = null; }, { once: true });
dialog.addEventListener("keydown", event => { if (event.key === "Escape") event.stopPropagation(); });
api.addEventListener("status", event => {
const remaining = event.detail?.exec_info?.queue_remaining;
if (state && typeof remaining === "number") { state.busy = remaining > 0; controls(); }
}, { signal: abort.signal });
// Keep the native modal inside the settings dialog's DOM so Core's
// outside-click handling does not dismiss the underlying settings page.
const parent = event?.currentTarget?.closest?.('[role="dialog"], dialog') || document.body;
parent.append(dialog); dialog.showModal(); controls();
refresh().then(() => { if (!closed) message.textContent = ""; })
.catch(error => { if (!closed) message.textContent = error.message; })
.finally(() => { pending = false; if (!closed) controls(); });
}
app.registerExtension({
name: "H3Continuum.TemporaryStorage",
setup() {
app.ui.settings.addSetting({
id: "H3Continuum.Storage.Manager",
name: "H3 Continuum: Temporary Storage",
category: ["H3Continuum", "Storage", "Temporary Storage"],
type: () => {
const row = element("tr");
const cell = element("td", null, row); cell.colSpan = 2;
const button = element("button", language().open, cell);
button.type = "button"; button.addEventListener("click", openStorageDialog);
return row;
},
defaultValue: null,
});
},
});