omnius 1.0.923 → 1.0.925

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/dist/{providerRegistry.d.ts → _types/backend-vllm/providerRegistry.d.ts} +0 -1
  2. package/dist/_types/backend-vllm/types.d.ts +209 -0
  3. package/dist/_types/execution/av/media-capability.d.ts +94 -0
  4. package/dist/_types/execution/delegation-contract.d.ts +102 -0
  5. package/dist/_types/execution/evidence.d.ts +68 -0
  6. package/dist/_types/execution/html-source-evidence.d.ts +65 -0
  7. package/dist/_types/execution/mcp/types.d.ts +169 -0
  8. package/dist/_types/execution/mutation-contract.d.ts +102 -0
  9. package/dist/_types/execution/nol/artifacts.d.ts +39 -0
  10. package/dist/_types/execution/nol/checkpoint-edits.d.ts +98 -0
  11. package/dist/_types/execution/nol/distributions.d.ts +128 -0
  12. package/dist/_types/execution/nol/gguf-checkpoint-edits.d.ts +194 -0
  13. package/dist/_types/execution/nol/gguf-control-reader.d.ts +224 -0
  14. package/dist/_types/execution/nol/lora-exports.d.ts +129 -0
  15. package/dist/_types/execution/nol/neuronary.d.ts +212 -0
  16. package/dist/_types/execution/nol/pytorch-control-reader.d.ts +143 -0
  17. package/dist/_types/execution/nol/qwen35-head-sites.d.ts +61 -0
  18. package/dist/_types/execution/nol/worker-assets.d.ts +82 -0
  19. package/dist/_types/execution/nol/worker-protocol.d.ts +94 -0
  20. package/dist/_types/execution/page-content-source.d.ts +40 -0
  21. package/dist/_types/execution/rapid-computer-use/artifact-store.d.ts +21 -0
  22. package/dist/_types/execution/rapid-computer-use/contracts.d.ts +320 -0
  23. package/dist/_types/execution/rapid-computer-use/decision.d.ts +70 -0
  24. package/dist/_types/execution/rapid-computer-use/desktop-verification.d.ts +23 -0
  25. package/dist/_types/execution/rapid-computer-use/geometry.d.ts +57 -0
  26. package/dist/_types/execution/rapid-computer-use/planner.d.ts +78 -0
  27. package/dist/_types/execution/rapid-computer-use/trace.d.ts +80 -0
  28. package/dist/_types/execution/rapid-computer-use/visual.d.ts +48 -0
  29. package/dist/_types/execution/shell-runs.d.ts +78 -0
  30. package/dist/_types/execution/streamed-web-source.d.ts +64 -0
  31. package/dist/_types/execution/tools/browser-page-fallback.d.ts +25 -0
  32. package/dist/_types/execution/tools/network-egress-policy.d.ts +30 -0
  33. package/dist/_types/execution/tools/pdf-native-tables.d.ts +46 -0
  34. package/dist/_types/execution/tools/todo-store.d.ts +133 -0
  35. package/dist/_types/execution/tools/web-fetch.d.ts +57 -0
  36. package/dist/_types/execution/tools/workboard.d.ts +1223 -0
  37. package/dist/_types/execution/types.d.ts +549 -0
  38. package/dist/_types/execution/web-source.d.ts +14 -0
  39. package/dist/_types/memory/artifactReviewSourceIndex.d.ts +133 -0
  40. package/dist/_types/memory/contextMemoryLedger.d.ts +213 -0
  41. package/dist/_types/memory/db.d.ts +12 -0
  42. package/dist/_types/memory/embeddings.d.ts +36 -0
  43. package/dist/_types/memory/immutableEvidenceStore.d.ts +165 -0
  44. package/dist/_types/memory/memoryIngestion.d.ts +65 -0
  45. package/dist/_types/memory/memoryTypes.d.ts +312 -0
  46. package/dist/_types/memory/sourceCorpusStore.d.ts +331 -0
  47. package/dist/_types/memory/structuredMemoryStore.d.ts +105 -0
  48. package/dist/_types/memory/unifiedMemoryStore.d.ts +127 -0
  49. package/dist/_types/memory/virtualMemory.d.ts +187 -0
  50. package/dist/_types/orchestrator/agentic-page-content-receipt.d.ts +20 -0
  51. package/dist/_types/orchestrator/agentic-web-fetch-receipt.d.ts +20 -0
  52. package/dist/_types/orchestrator/agenticRunner.d.ts +5219 -0
  53. package/dist/_types/orchestrator/app-state.d.ts +171 -0
  54. package/dist/_types/orchestrator/artifactClaimCritic.d.ts +63 -0
  55. package/dist/_types/orchestrator/artifactQuality.d.ts +15 -0
  56. package/dist/_types/orchestrator/artifactSemanticIntegrity.d.ts +203 -0
  57. package/dist/_types/orchestrator/canonical-context-projection.d.ts +254 -0
  58. package/dist/_types/orchestrator/canonical-source-body-projection.d.ts +51 -0
  59. package/dist/_types/orchestrator/completion-review-pending.d.ts +24 -0
  60. package/dist/_types/orchestrator/completionContract.d.ts +103 -0
  61. package/dist/_types/orchestrator/completionFinalization.d.ts +224 -0
  62. package/dist/_types/orchestrator/completionLedger.d.ts +429 -0
  63. package/dist/_types/orchestrator/completionReadiness.d.ts +234 -0
  64. package/dist/_types/orchestrator/context-admission.d.ts +93 -0
  65. package/dist/_types/orchestrator/context-dump-retention.d.ts +25 -0
  66. package/dist/_types/orchestrator/context-fabric.d.ts +133 -0
  67. package/dist/_types/orchestrator/contextEngine.d.ts +68 -0
  68. package/dist/_types/orchestrator/contextWindowDump.d.ts +327 -0
  69. package/dist/_types/orchestrator/convergence-breaker.d.ts +225 -0
  70. package/dist/_types/orchestrator/convergence-progress.d.ts +66 -0
  71. package/dist/_types/orchestrator/deliveryCoverage.d.ts +181 -0
  72. package/dist/_types/orchestrator/document-persistence-goal-binding.d.ts +106 -0
  73. package/dist/_types/orchestrator/durable-document-worker.d.ts +85 -0
  74. package/dist/_types/orchestrator/evidenceBranch.d.ts +291 -0
  75. package/dist/_types/orchestrator/expected-inference-response.d.ts +55 -0
  76. package/dist/_types/orchestrator/expectedOutcomeContract.d.ts +58 -0
  77. package/dist/_types/orchestrator/failure-taxonomy.d.ts +36 -0
  78. package/dist/_types/orchestrator/focusSupervisor.d.ts +436 -0
  79. package/dist/_types/orchestrator/forced-update-requirement-recovery.d.ts +105 -0
  80. package/dist/_types/orchestrator/hooks.d.ts +100 -0
  81. package/dist/_types/orchestrator/inference-pressure.d.ts +61 -0
  82. package/dist/_types/orchestrator/integrationClosure.d.ts +89 -0
  83. package/dist/_types/orchestrator/interruption-lifecycle.d.ts +154 -0
  84. package/dist/_types/orchestrator/live-memory-passages.d.ts +51 -0
  85. package/dist/_types/orchestrator/liveVirtualContext.d.ts +84 -0
  86. package/dist/_types/orchestrator/memory-compiler.d.ts +254 -0
  87. package/dist/_types/orchestrator/memory-consolidation.d.ts +134 -0
  88. package/dist/_types/orchestrator/model-router.d.ts +17 -0
  89. package/dist/_types/orchestrator/modelResponseDiagnostics.d.ts +71 -0
  90. package/dist/_types/orchestrator/nativeRequirementAmendment.d.ts +63 -0
  91. package/dist/_types/orchestrator/nol/coordinator.d.ts +204 -0
  92. package/dist/_types/orchestrator/nol/datasets.d.ts +58 -0
  93. package/dist/_types/orchestrator/nol/discovery.d.ts +286 -0
  94. package/dist/_types/orchestrator/nol/evaluation.d.ts +59 -0
  95. package/dist/_types/orchestrator/nol/model-validation.d.ts +198 -0
  96. package/dist/_types/orchestrator/nol/statistics.d.ts +142 -0
  97. package/dist/_types/orchestrator/nol/store.d.ts +133 -0
  98. package/dist/_types/orchestrator/nol/variant-registry.d.ts +292 -0
  99. package/dist/_types/orchestrator/ollama-context-policy.d.ts +34 -0
  100. package/dist/_types/orchestrator/personality.d.ts +66 -0
  101. package/dist/_types/orchestrator/prompt-cache.d.ts +24 -0
  102. package/dist/_types/orchestrator/remote-inference-fallback.d.ts +224 -0
  103. package/dist/_types/orchestrator/remote-inference-policy.d.ts +58 -0
  104. package/dist/_types/orchestrator/request-budget.d.ts +75 -0
  105. package/dist/_types/orchestrator/requirementCoverage.d.ts +69 -0
  106. package/dist/_types/orchestrator/reviewedInterpretation.d.ts +111 -0
  107. package/dist/_types/orchestrator/runEvents.d.ts +115 -0
  108. package/dist/_types/orchestrator/runtime-rollout.d.ts +63 -0
  109. package/dist/_types/orchestrator/semanticVerification.d.ts +135 -0
  110. package/dist/_types/orchestrator/source-wide-extraction.d.ts +202 -0
  111. package/dist/_types/orchestrator/steeringIntake.d.ts +123 -0
  112. package/dist/_types/orchestrator/structured-memory-extraction-worker.d.ts +89 -0
  113. package/dist/_types/orchestrator/structuredMemoryInference.d.ts +62 -0
  114. package/dist/_types/orchestrator/successful-procedure-memory.d.ts +127 -0
  115. package/dist/_types/orchestrator/supportedAnswer.d.ts +68 -0
  116. package/dist/_types/orchestrator/taskEffectEvidence.d.ts +38 -0
  117. package/dist/_types/orchestrator/taskExecutionSnapshot.d.ts +67 -0
  118. package/dist/_types/orchestrator/taskObjective.d.ts +310 -0
  119. package/dist/_types/orchestrator/taskObjectiveContinuation.d.ts +134 -0
  120. package/dist/_types/orchestrator/taskRequirementReview.d.ts +246 -0
  121. package/dist/_types/orchestrator/taskRequirements.d.ts +80 -0
  122. package/dist/_types/orchestrator/taskSemanticAdmission.d.ts +159 -0
  123. package/dist/_types/orchestrator/taskWorkDelegation.d.ts +147 -0
  124. package/dist/_types/orchestrator/taskWorkPlan.d.ts +177 -0
  125. package/dist/_types/orchestrator/telegram-passive-history.d.ts +42 -0
  126. package/dist/_types/orchestrator/terminalTaskReport.d.ts +91 -0
  127. package/dist/_types/orchestrator/todoObservability.d.ts +147 -0
  128. package/dist/_types/orchestrator/tool-exposure-policy.d.ts +100 -0
  129. package/dist/_types/orchestrator/trajectory-checkpoint.d.ts +159 -0
  130. package/dist/_types/orchestrator/types.d.ts +185 -0
  131. package/dist/_types/schemas/dispatch.d.ts +53 -0
  132. package/dist/_types/schemas/feature-workflow.d.ts +362 -0
  133. package/dist/_types/schemas/messages.d.ts +15 -0
  134. package/dist/_types/schemas/nol-assets.d.ts +955 -0
  135. package/dist/_types/schemas/nol-json.d.ts +2 -0
  136. package/dist/_types/schemas/nol.d.ts +3995 -0
  137. package/dist/_types/schemas/patch.d.ts +47 -0
  138. package/dist/_types/schemas/plan.d.ts +47 -0
  139. package/dist/_types/schemas/repoProfile.d.ts +116 -0
  140. package/dist/_types/schemas/retrieval.d.ts +44 -0
  141. package/dist/_types/schemas/task.d.ts +57 -0
  142. package/dist/_types/schemas/tools.d.ts +16 -0
  143. package/dist/_types/schemas/verification.d.ts +31 -0
  144. package/dist/api/py-embed.js +3353 -1829
  145. package/dist/assets/nol-checkpoint-editor.py +701 -0
  146. package/dist/assets/nol-gguf-checkpoint-editor.py +785 -0
  147. package/dist/assets/nol-gguf-control-reader.py +428 -0
  148. package/dist/assets/nol-gne-tools-worker.py +425 -0
  149. package/dist/assets/nol-gne-worker.py +1081 -0
  150. package/dist/assets/nol-lora-exporter.py +349 -0
  151. package/dist/assets/nol-pytorch-control-reader.py +470 -0
  152. package/dist/assets/nol-transformers-nnsight-worker.py +512 -0
  153. package/dist/assets/nol-transformers-peft-validation-worker.py +385 -0
  154. package/dist/assets/nol-transformers-peft-worker.py +488 -0
  155. package/dist/assets/nol-transformers-research-worker.py +472 -0
  156. package/dist/assets/nol-transformers-worker.py +920 -0
  157. package/dist/assets/nol-vllm-owned-worker.py +803 -0
  158. package/dist/assets/nol-vllm-runtime.py +695 -0
  159. package/dist/assets/nol-vllm-tokenizer.py +93 -0
  160. package/dist/assets/nol-vllm-worker.py +201 -0
  161. package/dist/computer-use/configured-planner.d.ts +37 -0
  162. package/dist/computer-use/configured-point.d.ts +35 -0
  163. package/dist/computer-use/host-session.d.ts +60 -0
  164. package/dist/computer-use/runner-ui-port.d.ts +37 -0
  165. package/dist/computer-use/session-review.d.ts +14 -0
  166. package/dist/computer-use/task-spec.d.ts +84 -0
  167. package/dist/discovery.d.ts +16 -2
  168. package/dist/index.js +2 -2
  169. package/dist/library.d.ts +94 -10
  170. package/dist/library.js +144003 -87414
  171. package/dist/memory-maintenance-worker.js +1676 -511
  172. package/dist/nol/cpu-control-reader-profile.d.ts +93 -0
  173. package/dist/nol/cpu-control-reader-service.d.ts +87 -0
  174. package/dist/nol/cuda-lease.d.ts +111 -0
  175. package/dist/nol/cuda-mutations.d.ts +34 -0
  176. package/dist/nol/export-runtime-config.d.ts +114 -0
  177. package/dist/nol/export-service.d.ts +143 -0
  178. package/dist/nol/facade.d.ts +147 -0
  179. package/dist/nol/gguf-cpu-control-reader-profile.d.ts +106 -0
  180. package/dist/nol/gguf-cpu-control-reader-service.d.ts +91 -0
  181. package/dist/nol/gguf-model-control-verifier.d.ts +120 -0
  182. package/dist/nol/gguf-parameter-inventory.d.ts +28 -0
  183. package/dist/nol/gne-adapter.d.ts +134 -0
  184. package/dist/nol/gne-agent-evaluation.d.ts +84 -0
  185. package/dist/nol/gne-profile.d.ts +124 -0
  186. package/dist/nol/gne-tools-profile.d.ts +148 -0
  187. package/dist/nol/gne-tools-transport.d.ts +194 -0
  188. package/dist/nol/model-actions.d.ts +662 -0
  189. package/dist/nol/model-control-verifier.d.ts +135 -0
  190. package/dist/nol/model-json-scorer.d.ts +13 -0
  191. package/dist/nol/model-runtime-config.d.ts +830 -0
  192. package/dist/nol/model-serving.d.ts +130 -0
  193. package/dist/nol/model-subject-adapter.d.ts +72 -0
  194. package/dist/nol/model-validation-factory.d.ts +113 -0
  195. package/dist/nol/neuronary-catalog.d.ts +130 -0
  196. package/dist/nol/orphan-custody.d.ts +72 -0
  197. package/dist/nol/peft-conformance.d.ts +48 -0
  198. package/dist/nol/peft-control-types.d.ts +137 -0
  199. package/dist/nol/peft-control-verifier.d.ts +8 -0
  200. package/dist/nol/peft-model-actions.d.ts +41 -0
  201. package/dist/nol/peft-model-authority.d.ts +146 -0
  202. package/dist/nol/peft-model-controls.d.ts +20 -0
  203. package/dist/nol/peft-model-host.d.ts +47 -0
  204. package/dist/nol/peft-model-profile.d.ts +161 -0
  205. package/dist/nol/peft-model-runtime-config.d.ts +174 -0
  206. package/dist/nol/peft-model-subject-adapter.d.ts +36 -0
  207. package/dist/nol/peft-validation.d.ts +105 -0
  208. package/dist/nol/persistent-parameter-inventory.d.ts +32 -0
  209. package/dist/nol/runtime.d.ts +100 -0
  210. package/dist/nol/sqlite-store.d.ts +80 -0
  211. package/dist/nol/transformers-adapter.d.ts +119 -0
  212. package/dist/nol/transformers-nnsight.d.ts +87 -0
  213. package/dist/nol/transformers-peft.d.ts +107 -0
  214. package/dist/nol/transformers-research.d.ts +114 -0
  215. package/dist/nol/variant-service.d.ts +143 -0
  216. package/dist/nol/variant-store.d.ts +51 -0
  217. package/dist/nol/vllm-actions.d.ts +774 -0
  218. package/dist/nol/vllm-adapter.d.ts +1473 -0
  219. package/dist/nol/vllm-authority.d.ts +55 -0
  220. package/dist/nol/vllm-conformance.d.ts +662 -0
  221. package/dist/nol/vllm-profile.d.ts +850 -0
  222. package/dist/nol/vllm-protocol.d.ts +1505 -0
  223. package/dist/nol/vllm-runtime-config.d.ts +120 -0
  224. package/dist/nol/vllm-runtime.d.ts +34 -0
  225. package/dist/nol/vllm-startup.d.ts +235 -0
  226. package/dist/omni-setup-worker.js +3433 -1909
  227. package/dist/service-version.d.ts +0 -1
  228. package/dist/tui/async-process.d.ts +27 -0
  229. package/dist/tui/native/worker.js +3 -1
  230. package/dist/tui/telegram-action-session-registry.d.ts +136 -0
  231. package/dist/tui/telegram-cognition-queue.d.ts +154 -0
  232. package/dist/tui/telegram-context-packet-v2.d.ts +99 -0
  233. package/dist/tui/telegram-input-ownership.d.ts +78 -0
  234. package/dist/tui/telegram-turn-contract-v2.d.ts +62 -0
  235. package/dist/update-worker-runtime.js +4216 -2603
  236. package/docs/DISCOVERY.json +389 -0
  237. package/docs/DISCOVERY.md +4 -0
  238. package/npm-shrinkwrap.json +28 -12
  239. package/package.json +3 -2
@@ -0,0 +1,470 @@
1
+ #!/usr/bin/env python3
2
+ """Pinned, read-only CPU storage inventory. Never constructs a neural model.
3
+
4
+ The original editor supplies the complete symbolic ZIP/pickle admission before
5
+ Torch is imported. This extension projects byte ranges, then checks every range
6
+ against the actual weights_only/CPU/mmap Tensor. The report contains no tensor
7
+ values and grants no numerical-control, native, or scientific authority.
8
+ """
9
+ import ctypes
10
+ import gc
11
+ import hashlib
12
+ import importlib.metadata
13
+ import importlib.util
14
+ import io
15
+ import json
16
+ import math
17
+ import os
18
+ from pathlib import Path
19
+ import pickle
20
+ import pickletools
21
+ import re
22
+ import resource
23
+ import signal
24
+ import stat
25
+ import struct
26
+ import sys
27
+ import time
28
+ import zipfile
29
+ from collections import OrderedDict
30
+
31
+ SCHEMA = "omnius.nol.pytorch-control-reader-request.v1"
32
+ EDITOR_SHA = "aaee38b90eab4f0526610ad3ceea5e5be54890d1bdc49c57a2cf5d4fe3766570"
33
+ CODE = re.compile(r"(?:\.(?:py|pyi|pyd|dll|dylib|pth)|\.so(?:\.\d+)*)$|\.dist-info/(?:METADATA|WHEEL|entry_points\.txt)$")
34
+ LIMITS = {"maxInputBytes", "maxWorkingBytes", "maxReadBytes", "maxTensors", "maxCoordinates",
35
+ "maxRuntimeBytes", "maxRuntimeFiles", "maxDurationMs", "maxProtocolBytes",
36
+ "maxStderrBytes", "chunkBytes", "maxReportBytes", "maxAddressSpaceBytes"}
37
+
38
+
39
+ def need(ok, message):
40
+ if not ok:
41
+ raise ValueError(message)
42
+
43
+
44
+ def fields(value, required, optional=()):
45
+ need(type(value) is dict and set(required) <= value.keys() <= set(required) | set(optional), "Unknown/missing reader fields")
46
+
47
+
48
+ def pairs(items):
49
+ result = {}
50
+ for key, value in items:
51
+ need(key not in result, "Duplicate JSON key")
52
+ result[key] = value
53
+ return result
54
+
55
+
56
+ def parse(raw):
57
+ return json.loads(raw, object_pairs_hook=pairs, parse_constant=lambda _: (_ for _ in ()).throw(ValueError("Nonfinite JSON")),
58
+ parse_int=lambda text: -0.0 if text == "-0" else int(text))
59
+
60
+
61
+ def encoded(value):
62
+ return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":"), allow_nan=False).encode()
63
+
64
+
65
+ def integer(value, minimum=0, maximum=9007199254740991):
66
+ need(type(value) is int and minimum <= value <= maximum, "Invalid reader integer")
67
+ return value
68
+
69
+
70
+ def regular(path):
71
+ path = Path(path)
72
+ info = path.lstat()
73
+ need(stat.S_ISREG(info.st_mode) and not path.is_symlink() and path.resolve(strict=True) == path, "Reader source must be canonical nonsymlink regular file")
74
+ return info
75
+
76
+
77
+ def identity(info):
78
+ return (info.st_dev, info.st_ino, info.st_size, info.st_mtime_ns, info.st_ctime_ns)
79
+
80
+
81
+ class Budget:
82
+ def __init__(self, limits):
83
+ fields(limits, LIMITS)
84
+ for value in limits.values():
85
+ integer(value, 1)
86
+ need(limits["maxProtocolBytes"] <= 16 * 1024 ** 2 and limits["maxStderrBytes"] <= 1024 ** 2 and
87
+ 4096 <= limits["chunkBytes"] <= 4 * 1024 ** 2 and limits["chunkBytes"] % 4 == 0 and
88
+ limits["maxDurationMs"] <= 86400000, "Unsupported reader limits")
89
+ self.limits, self.started = limits, time.monotonic()
90
+ self.read_bytes = self.working = self.runtime_bytes = self.runtime_files = 0
91
+ self.input = self.artifacts = self.arithmetic = 0
92
+ self.stamps = {}
93
+ self.directories = {}
94
+ self.reserve(limits["chunkBytes"] * 3)
95
+
96
+ def check(self):
97
+ need(time.monotonic() - self.started <= self.limits["maxDurationMs"] / 1000, "Reader wall-clock budget exceeded")
98
+
99
+ def read(self, count):
100
+ self.check()
101
+ self.read_bytes += integer(count)
102
+ need(self.read_bytes <= self.limits["maxReadBytes"], "Reader logical-read byte budget exceeded")
103
+
104
+ def reserve(self, count):
105
+ self.check()
106
+ self.working += integer(count)
107
+ need(self.working <= self.limits["maxWorkingBytes"], "Reader working-byte budget exceeded")
108
+
109
+ def guard(self):
110
+ self.check()
111
+ for path, stamp in self.stamps.items():
112
+ need(identity(regular(path)) == stamp, "Reader source/runtime/checkpoint changed")
113
+ for path, stamp in self.directories.items():
114
+ info = Path(path).lstat()
115
+ need(stat.S_ISDIR(info.st_mode) and not Path(path).is_symlink() and identity(info) == stamp, "Reader checkpoint directory inventory changed")
116
+
117
+
118
+ def hash_file(path, budget, maximum=None):
119
+ path = Path(path)
120
+ before = regular(path)
121
+ need(maximum is None or before.st_size <= maximum, "Reader file exceeds declared bound")
122
+ budget.read(before.st_size)
123
+ result, size = hashlib.sha256(), 0
124
+ with path.open("rb") as stream:
125
+ need(identity(os.fstat(stream.fileno())) == identity(before), "Reader file changed while opening")
126
+ while True:
127
+ budget.check()
128
+ block = stream.read(budget.limits["chunkBytes"])
129
+ if not block:
130
+ break
131
+ size += len(block)
132
+ need(size <= before.st_size, "Reader file grew")
133
+ result.update(block)
134
+ need(identity(os.fstat(stream.fileno())) == identity(before), "Reader file changed while hashing")
135
+ need(size == before.st_size and identity(regular(path)) == identity(before), "Reader file extent/identity changed")
136
+ budget.stamps[str(path)] = identity(before)
137
+ return {"sha256": result.hexdigest(), "sizeBytes": size}
138
+
139
+
140
+ def read_range(path, offset, count, budget):
141
+ info = regular(path)
142
+ integer(offset)
143
+ integer(count)
144
+ need(offset + count <= info.st_size, "Reader range escaped actual source")
145
+ budget.read(count)
146
+ with Path(path).open("rb") as stream:
147
+ need(identity(os.fstat(stream.fileno())) == identity(info), "Reader range source changed")
148
+ stream.seek(offset)
149
+ raw = stream.read(count)
150
+ need(len(raw) == count and identity(os.fstat(stream.fileno())) == identity(info), "Reader range truncated/changed")
151
+ return raw
152
+
153
+
154
+ def cpu_guard():
155
+ need(all(os.environ.get(key) == "-1" for key in ("CUDA_VISIBLE_DEVICES", "HIP_VISIBLE_DEVICES", "ROCR_VISIBLE_DEVICES")), "Explicit denied CUDA/HIP/ROCR visibility required")
156
+ need("torch" not in sys.modules and not any(name.startswith(("transformers", "llama_cpp", "gne")) for name in sys.modules), "Framework/model imported before CPU admission")
157
+ need(sys.byteorder == "little", "Only little-endian CPU storage is supported")
158
+
159
+
160
+ def load_editor(payload, budget):
161
+ cpu_guard()
162
+ own = hash_file(Path(__file__).resolve(strict=True), budget)
163
+ need(own["sha256"] == payload["expectedReaderSha256"], "Reader source pin mismatch")
164
+ path = Path(payload["checkpointEditorPath"])
165
+ source = hash_file(path, budget)
166
+ need(source["sha256"] == payload["expectedCheckpointEditorSha256"] == EDITOR_SHA, "Exact symbolic-admission editor pin mismatch")
167
+ spec = importlib.util.spec_from_file_location("nol_pinned_checkpoint_admission", path)
168
+ need(spec is not None and spec.loader is not None, "Pinned editor import unavailable")
169
+ editor = importlib.util.module_from_spec(spec)
170
+ # This pinned module is stdlib-only at import. Never register it as a
171
+ # substitutable package or execute its __main__ edit/publish entry point.
172
+ spec.loader.exec_module(editor)
173
+ cpu_guard()
174
+ original = editor.hash_file
175
+
176
+ def tracked_hash(path, original_budget=None):
177
+ budget.read(regular(path).st_size)
178
+ return original(path, original_budget)
179
+
180
+ editor.hash_file = tracked_hash
181
+ return editor, own, source
182
+
183
+
184
+ def runtime_inventory(payload, budget, own, editor_source):
185
+ packages, names = [], set()
186
+ for distribution in sorted(importlib.metadata.distributions(), key=lambda d: d.metadata.get("Name", "").lower()):
187
+ budget.check()
188
+ name = distribution.metadata.get("Name", "")
189
+ if not name:
190
+ continue
191
+ need(name.lower() not in names, "Ambiguous duplicate installed distribution")
192
+ names.add(name.lower())
193
+ entries, total = [], 0
194
+ for item in sorted(distribution.files or (), key=str):
195
+ text = str(item)
196
+ if not CODE.search(text) or "__pycache__" in text:
197
+ continue
198
+ path = Path(os.path.abspath(distribution.locate_file(item)))
199
+ info = regular(path)
200
+ budget.runtime_bytes += info.st_size
201
+ budget.runtime_files += 1
202
+ need(budget.runtime_bytes <= budget.limits["maxRuntimeBytes"] and budget.runtime_files <= budget.limits["maxRuntimeFiles"], "Reader runtime inventory budget exceeded")
203
+ actual = hash_file(path, budget)
204
+ total += actual["sizeBytes"]
205
+ entries.append({"path": text, **actual})
206
+ packages.append({"name": name, "version": distribution.version, "files": len(entries), "bytes": total,
207
+ "digest": hashlib.sha256(encoded(entries)).hexdigest()})
208
+ need(any(p["name"].lower() == "torch" for p in packages), "Explicit CPU Torch reader environment unavailable")
209
+ body = {"schema": "omnius.nol.pytorch-control-reader-runtime.v1", "pythonVersion": sys.version.split()[0],
210
+ "pythonExecutable": hash_file(Path(sys.executable).resolve(strict=True), budget), "packages": packages,
211
+ "reader": own, "checkpointEditor": editor_source,
212
+ "dependencyLock": hash_file(Path(payload["dependencyLockPath"]), budget, 1024 ** 2)}
213
+ cpu_guard()
214
+ return {**body, "runtimeDigest": hashlib.sha256(encoded(body)).hexdigest()}
215
+
216
+
217
+ def central_admission(path, budget):
218
+ """Bound ZIP metadata BEFORE ZipFile allocates its central-directory list."""
219
+ size = regular(path).st_size
220
+ need(size >= 22 and read_range(path, 0, 4, budget) == b"PK\x03\x04", "Legacy/non-ZIP or prefixed PyTorch checkpoint unsupported")
221
+ start = max(0, size - 65557)
222
+ tail = read_range(path, start, size - start, budget)
223
+ end = tail.rfind(b"PK\x05\x06")
224
+ need(end >= 0 and end + 22 <= len(tail), "Missing ZIP central-directory terminator")
225
+ _, disk, central_disk, disk_entries, entries, central_bytes, central_offset, comment = struct.unpack_from("<4s4H2IH", tail, end)
226
+ need(end + 22 + comment == len(tail) and disk == central_disk == 0 and entries == disk_entries, "Multidisk/trailing ZIP metadata unsupported")
227
+ bound = start + end
228
+ if entries == 65535 or central_bytes == 0xffffffff or central_offset == 0xffffffff:
229
+ need(bound >= 20, "Missing ZIP64 locator")
230
+ locator = read_range(path, bound - 20, 20, budget)
231
+ signature, locator_disk, record_offset, disks = struct.unpack("<4sIQI", locator)
232
+ need(signature == b"PK\x06\x07" and locator_disk == 0 and disks == 1, "Invalid ZIP64 locator")
233
+ record = read_range(path, record_offset, 56, budget)
234
+ signature, extent, _, _, disk, central_disk, disk_entries, entries, central_bytes, central_offset = struct.unpack("<4sQ2H2I4Q", record)
235
+ need(signature == b"PK\x06\x06" and extent == 44 and disk == central_disk == 0 and entries == disk_entries, "Unsupported ZIP64 directory")
236
+ bound = record_offset
237
+ need(0 < entries <= budget.limits["maxTensors"] * 4 + 32 and central_bytes <= budget.limits["maxProtocolBytes"] and
238
+ central_offset + central_bytes <= bound, "ZIP central-directory allocation/extent budget exceeded")
239
+ budget.reserve(central_bytes * 8 + entries * 1024)
240
+
241
+
242
+ def project(path, editor, budget):
243
+ # Complete original admission, unchanged and before Torch. The second
244
+ # unpickler only projects ranges; actual Tensor objects verify it later.
245
+ with zipfile.ZipFile(path) as precheck:
246
+ records = precheck.infolist()
247
+ need(all(entry.compress_type == zipfile.ZIP_STORED and not entry.flag_bits & 1 for entry in records), "Compressed/encrypted ZIP refused before pickle read")
248
+ pickle_records = [entry for entry in records if entry.filename.endswith("/data.pkl")]
249
+ need(len(pickle_records) == 1 and pickle_records[0].file_size <= budget.limits["maxProtocolBytes"], "Bounded single Tensor pickle required")
250
+ raw = precheck.read(pickle_records[0])
251
+ budget.read(len(raw))
252
+ operations = 0
253
+ for opcode, argument, _ in pickletools.genops(raw):
254
+ operations += 1
255
+ need(operations <= budget.limits["maxProtocolBytes"], "Pickle opcode work budget exceeded")
256
+ if opcode.name in ("LONG_BINPUT", "BINPUT", "LONG_BINGET", "BINGET", "PUT", "GET"):
257
+ need(0 <= int(argument) <= min(budget.limits["maxProtocolBytes"], budget.limits["maxTensors"] * 64 + 256), "Pickle memo allocation budget exceeded")
258
+ if opcode.name == "FRAME":
259
+ need(argument <= len(raw), "Pickle FRAME allocation exceeds actual metadata")
260
+ editor.zip_admission(path, budget)
261
+ with zipfile.ZipFile(path) as archive:
262
+ entries = archive.infolist()
263
+ pickle_entry = next(e for e in entries if e.filename.endswith("/data.pkl"))
264
+ prefix = pickle_entry.filename[:-len("data.pkl")]
265
+ need(prefix + "byteorder" in archive.namelist() and archive.read(prefix + "byteorder") == b"little", "Explicit little-endian ZIP byteorder required")
266
+ storages = {e.filename[len(prefix + "data/"):]: e for e in entries if e.filename.startswith(prefix + "data/")}
267
+ raw_pickle = archive.read(pickle_entry)
268
+ budget.read(pickle_entry.file_size * 4)
269
+ widths = {"FloatStorage": ("F32", 4), "HalfStorage": ("F16", 2), "BFloat16Storage": ("BF16", 2)}
270
+
271
+ class Projection(pickle.Unpickler):
272
+ def find_class(self, module, name):
273
+ if module == "torch" and name in widths:
274
+ return widths[name]
275
+ if module == "collections" and name == "OrderedDict":
276
+ return OrderedDict
277
+ if module == "torch._utils" and name in ("_rebuild_tensor", "_rebuild_tensor_v2"):
278
+ return self.tensor
279
+ raise ValueError("Unsupported PyTorch range-projection reducer/dtype")
280
+
281
+ def persistent_load(self, value):
282
+ need(type(value) is tuple and len(value) == 5 and value[0] == "storage" and type(value[1]) is tuple and
283
+ len(value[1]) == 2 and value[1] in widths.values() and type(value[2]) is str and value[2] in storages and
284
+ type(value[3]) is str and (value[3] == "cpu" or re.fullmatch(r"cuda:\d+", value[3])), "Unsupported typed storage device tag")
285
+ count = integer(value[4])
286
+ need(count * value[1][1] == storages[value[2]].file_size, "Projected storage extent mismatch")
287
+ return {"key": value[2], "dtype": value[1][0], "width": value[1][1], "elements": count}
288
+
289
+ @staticmethod
290
+ def tensor(storage, offset, size, stride, requires_grad=False, hooks=None, metadata=None):
291
+ need(type(storage) is dict and type(size) is tuple and type(stride) is tuple and len(size) == len(stride) <= 8 and
292
+ metadata in (None, {}) and not hooks, "Unsupported projected Tensor metadata")
293
+ count, step = 1, 1
294
+ for dimension in size:
295
+ count *= integer(dimension)
296
+ integer(count)
297
+ for dimension, actual_stride in reversed(list(zip(size, stride))):
298
+ need(integer(actual_stride) == step or dimension <= 1, "Noncontiguous Tensor storage unsupported")
299
+ step *= max(1, dimension)
300
+ need(integer(offset) == 0 and count == storage["elements"], "Narrowed/offset Tensor storage views unsupported")
301
+ return {**storage, "shape": list(size), "stride": list(stride), "elements": count}
302
+
303
+ stream = io.BytesIO(raw_pickle)
304
+ result = Projection(stream).load()
305
+ need(stream.tell() == len(raw_pickle) and isinstance(result, dict) and result and
306
+ all(type(name) is str and name and "\0" not in name and type(item) is dict and "key" in item for name, item in result.items()), "Flat projected tensor-only state required")
307
+ need(len(result) <= budget.limits["maxTensors"] and sum(t["elements"] for t in result.values()) <= budget.limits["maxCoordinates"], "Projected Tensor inventory/coordinate budget exceeded")
308
+ need({t["key"] for t in result.values()} == set(storages), "Unreferenced/missing physical storage")
309
+ by_storage = {}
310
+ for item in result.values():
311
+ by_storage.setdefault(item["key"], []).append(item)
312
+ offsets = sorted(entry.header_offset for entry in entries)
313
+ next_offsets = dict(zip(offsets, offsets[1:] + [archive.start_dir]))
314
+ for key, entry in storages.items():
315
+ header = read_range(path, entry.header_offset, 30, budget)
316
+ signature, _, flags, compression, _, _, _, _, _, name_size, extra_size = struct.unpack("<4s5H3I2H", header)
317
+ need(signature == b"PK\x03\x04" and flags == entry.flag_bits and not flags & 1 and compression == zipfile.ZIP_STORED, "ZIP local/central header mismatch")
318
+ raw_name = read_range(path, entry.header_offset + 30, name_size, budget)
319
+ need(raw_name.decode("utf-8" if flags & 0x800 else "cp437") == entry.filename, "ZIP local storage filename mismatch")
320
+ first = entry.header_offset + 30 + name_size + extra_size
321
+ next_header = next_offsets[entry.header_offset]
322
+ need(first + entry.file_size <= next_header, "Overlapping ZIP storage data range")
323
+ for item in by_storage[key]:
324
+ item["dataOffsetBytes"] = first
325
+ item["sizeBytes"] = entry.file_size
326
+ return result
327
+
328
+
329
+ def inventory(payload, editor, runtime, budget):
330
+ model, root = payload["model"], Path(payload["checkpointRoot"])
331
+ need(root.is_absolute() and root.resolve(strict=True) == root and not root.is_symlink(), "Canonical checkpoint root required")
332
+ need(model.get("format") in ("pytorch", "hf") and model.get("quantization", {}).get("method") == "none", "Only unquantized PyTorch checkpoints supported")
333
+ total = sum(integer(f["artifact"]["sizeBytes"]) for f in model["files"])
334
+ need(total <= budget.limits["maxInputBytes"], "Reader aggregate model input cap exceeded")
335
+ expected = {file["path"] for file in model["files"]}
336
+ need(len(expected) == len(model["files"]), "Duplicate checkpoint path")
337
+ directories, actual = [root], set()
338
+ while directories:
339
+ directory = directories.pop()
340
+ budget.check()
341
+ info = directory.lstat()
342
+ need(stat.S_ISDIR(info.st_mode) and not directory.is_symlink(), "Checkpoint directory symlink unsupported")
343
+ budget.directories[str(directory)] = identity(info)
344
+ need(len(budget.directories) <= len(expected) * 2 + 32, "Checkpoint directory work bound exceeded")
345
+ with os.scandir(directory) as entries:
346
+ for entry in entries:
347
+ budget.check()
348
+ need(not entry.is_symlink(), "Checkpoint symlink unsupported")
349
+ path = Path(entry.path)
350
+ if entry.is_dir(follow_symlinks=False):
351
+ directories.append(path)
352
+ else:
353
+ name = path.relative_to(root).as_posix()
354
+ need(entry.is_file(follow_symlinks=False) and name in expected, "Unmanifested/nonregular checkpoint source")
355
+ actual.add(name)
356
+ need(len(actual) <= len(expected), "Checkpoint inventory bound exceeded")
357
+ need(actual == expected, "Missing complete checkpoint inventory")
358
+ projections = {}
359
+ for file in model["files"]:
360
+ actual = hash_file(editor.safe(root, file["path"]), budget)
361
+ need(actual == {"sha256": file["artifact"]["sha256"], "sizeBytes": file["artifact"]["sizeBytes"]}, "Complete frozen checkpoint hash mismatch before metadata admission")
362
+ if file["role"] == "weights":
363
+ path = editor.safe(root, file["path"])
364
+ central_admission(path, budget)
365
+ # Project/admit before Checkpoint's repeated original guard as well; the
366
+ # extra memo/frame bound protects the stdlib unpickler's own allocation.
367
+ for file in model["files"]:
368
+ if file["role"] == "weights":
369
+ need(file["path"].endswith((".bin", ".pt", ".pth")), "Mixed/safetensors physical codec unsupported by PyTorch reader")
370
+ projections[file["path"]] = project(editor.safe(root, file["path"]), editor, budget)
371
+ checkpoint = editor.Checkpoint(model, root, payload["identity"], budget)
372
+ need(checkpoint.kind == "torch", "Mixed/safetensors physical codec unsupported by PyTorch reader")
373
+ need(sum(len(items) for items in projections.values()) <= budget.limits["maxTensors"], "Aggregate Tensor inventory cap exceeded")
374
+ need(sum(item["elements"] for items in projections.values() for item in items.values()) <= budget.limits["maxCoordinates"], "Aggregate Tensor coordinate cap exceeded")
375
+ names = [name for items in projections.values() for name in items]
376
+ need(len(set(names)) == len(names), "Duplicate projected Tensor across shards")
377
+ # All complete model bytes, ZIP/pickle metadata, resource bounds and the
378
+ # full pinned runtime must be admitted BEFORE the first Torch import.
379
+ actual_runtime = runtime()
380
+ need(editor.same(actual_runtime, payload["runtime"]), "Pinned reader runtime changed")
381
+ cpu_guard()
382
+ import torch
383
+ need(torch.cuda.is_initialized() is False, "CPU reader unexpectedly initialized CUDA")
384
+ torch.set_num_threads(1)
385
+ # Conservative native mmap/metadata read allowance, not a claim about
386
+ # physical disk IO or page-cache traffic. Explicit hash/range/memory reads
387
+ # are separately charged below.
388
+ budget.read(total * 2)
389
+ checkpoint.load_torch(torch)
390
+ tensors, aliases, seen = [], {}, set()
391
+ dtype_names = {torch.float32: "F32", torch.float16: "F16", torch.bfloat16: "BF16"}
392
+ for source, items in projections.items():
393
+ state = checkpoint.states[source]
394
+ need(set(state) == set(items), "Actual Tensor inventory differs from symbolic projection")
395
+ for name, projected in items.items():
396
+ budget.check()
397
+ need(name not in seen, "Duplicate Tensor across shards")
398
+ seen.add(name)
399
+ tensor = state[name]
400
+ need(type(tensor) is torch.Tensor and tensor.device.type == "cpu" and tensor.layout == torch.strided and
401
+ tensor.is_contiguous() and not tensor.is_quantized and tensor.dtype in dtype_names, "Unsupported actual Tensor dtype/layout/device")
402
+ need(dtype_names[tensor.dtype] == projected["dtype"] and list(tensor.shape) == projected["shape"] and list(tensor.stride()) == projected["stride"] and
403
+ tensor.storage_offset() == 0 and tensor.numel() * tensor.element_size() == tensor.untyped_storage().nbytes() == projected["sizeBytes"], "Actual Tensor metadata/storage differs from projection")
404
+ size, sha, path = projected["sizeBytes"], hashlib.sha256(), editor.safe(root, source)
405
+ for offset in range(0, size, budget.limits["chunkBytes"]):
406
+ budget.check()
407
+ count = min(budget.limits["chunkBytes"], size - offset)
408
+ budget.read(count)
409
+ memory = ctypes.string_at(tensor.data_ptr() + offset, count)
410
+ actual = read_range(path, projected["dataOffsetBytes"] + offset, count, budget)
411
+ need(memory == actual, "Actual mmap Tensor bits differ from frozen source storage range")
412
+ sha.update(memory)
413
+ group = source + ":" + projected["key"]
414
+ aliases.setdefault(group, []).append(name)
415
+ tensors.append({"name": name, "dtype": projected["dtype"], "shape": projected["shape"], "sourceFile": source,
416
+ "storageKey": projected["key"], "dataOffsetBytes": projected["dataOffsetBytes"], "sizeBytes": size,
417
+ "sha256": sha.hexdigest(), "elements": projected["elements"], "aliasGroup": group})
418
+ need(not torch.cuda.is_initialized(), "CPU Tensor read unexpectedly initialized CUDA")
419
+ files = []
420
+ for file in model["files"]:
421
+ path = editor.safe(root, file["path"])
422
+ actual = hash_file(path, budget)
423
+ need(actual == {"sha256": file["artifact"]["sha256"], "sizeBytes": file["artifact"]["sizeBytes"]}, "Checkpoint changed after mmap verification")
424
+ files.append({"path": file["path"], "role": file["role"], **actual})
425
+ checkpoint.states.clear()
426
+ del tensor
427
+ gc.collect()
428
+ budget.guard()
429
+ return {"schema": "omnius.nol.pytorch-control-inventory.v1", "modelDigest": model["modelDigest"],
430
+ "runtimeDigest": actual_runtime["runtimeDigest"], "readerSha256": actual_runtime["reader"]["sha256"],
431
+ "checkpointEditorSha256": EDITOR_SHA, "files": files, "tensors": sorted(tensors, key=lambda t: t["name"]),
432
+ "aliases": [{"id": key, "tensors": sorted(names)} for key, names in sorted(aliases.items()) if len(names) > 1],
433
+ "usage": {"inputBytes": total, "logicalReadBytes": budget.read_bytes, "reservedWorkingBytes": budget.working},
434
+ "symbolicAdmissionBeforeTorch": True, "weightsOnly": True, "mmap": True, "device": "cpu",
435
+ "cudaInitialized": False, "modelConstructed": False, "numericalControlVerified": False, "authority": "none"}
436
+
437
+
438
+ def main():
439
+ raw = sys.stdin.buffer.read(16 * 1024 ** 2 + 1)
440
+ need(len(raw) <= 16 * 1024 ** 2, "Absolute reader request cap exceeded")
441
+ payload = parse(raw)
442
+ fields(payload, ("schema", "action", "expectedReaderSha256", "checkpointEditorPath", "expectedCheckpointEditorSha256", "dependencyLockPath", "limits"),
443
+ ("runtime", "model", "checkpointRoot", "identity"))
444
+ need(payload["schema"] == SCHEMA and payload["action"] in ("inspect", "inventory"), "Unsupported reader action/schema")
445
+ budget = Budget(payload["limits"])
446
+ need(len(raw) <= budget.limits["maxProtocolBytes"], "Reader request protocol cap exceeded")
447
+ resource.setrlimit(resource.RLIMIT_AS, (budget.limits["maxAddressSpaceBytes"], budget.limits["maxAddressSpaceBytes"]))
448
+ resource.setrlimit(resource.RLIMIT_CPU, (max(1, math.ceil(budget.limits["maxDurationMs"] / 1000)), max(2, math.ceil(budget.limits["maxDurationMs"] / 1000) + 1)))
449
+ editor, own, source = load_editor(payload, budget)
450
+ runtime = lambda: runtime_inventory(payload, budget, own, source)
451
+ if payload["action"] == "inspect":
452
+ need(not any(key in payload for key in ("runtime", "model", "checkpointRoot", "identity")), "Inspect does not accept checkpoint/model input")
453
+ result = {"runtime": runtime(), "torchImported": False, "cudaInitialized": False, "modelConstructed": False}
454
+ budget.guard()
455
+ else:
456
+ need(all(key in payload for key in ("runtime", "model", "checkpointRoot", "identity")), "Frozen runtime/model input required")
457
+ result = inventory(payload, editor, runtime, budget)
458
+ raw = encoded(result)
459
+ need(len(raw) <= budget.limits["maxProtocolBytes"], "Reader response protocol cap exceeded")
460
+ sys.stdout.buffer.write(raw)
461
+ sys.stdout.flush()
462
+
463
+
464
+ if __name__ == "__main__":
465
+ try:
466
+ signal.signal(signal.SIGTERM, lambda *_: (_ for _ in ()).throw(InterruptedError("CPU reader Stop")))
467
+ main()
468
+ except BaseException as error:
469
+ sys.stderr.write((type(error).__name__ + ": " + str(error))[-4000:] + "; torchImported=" + str("torch" in sys.modules).lower() + "\n")
470
+ sys.exit(1)