omnius 1.0.923 → 1.0.924

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 +5216 -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 +26 -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 +137700 -81150
  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,428 @@
1
+ #!/usr/bin/env python3
2
+ """Bounded read-only GGUF storage inventory; no neural runtime or tensor decode.
3
+
4
+ The exact pinned editor Scanner admits the complete little-endian single-file
5
+ v3 directory. Code/runtime/lock hashes precede NumPy/GGUF imports. Reports contain
6
+ raw ranges/geometry/hashes, never tensor values or numerical control authority.
7
+ """
8
+ import hashlib
9
+ import importlib.metadata
10
+ import importlib.util
11
+ import json
12
+ import math
13
+ import os
14
+ from pathlib import Path
15
+ import re
16
+ import resource
17
+ import signal
18
+ import stat
19
+ import struct
20
+ import sys
21
+ import time
22
+
23
+ SCHEMA = "omnius.nol.gguf-control-reader-request.v1"
24
+ EDITOR_SHA = "fecf1d3ccb4b4d3964d15ae98b1da231e3eabb0aa5d3395f334cc6df24f9ea78"
25
+ CODE = re.compile(r"(?:\.(?:py|pyi|pyd|dll|dylib|pth)|\.so(?:\.\d+)*)$|\.dist-info/(?:METADATA|WHEEL|RECORD|entry_points\.txt)$")
26
+ LIMITS = {"maxInputBytes", "maxWorkingBytes", "maxReadBytes", "maxTensors", "maxCoordinates",
27
+ "maxRuntimeBytes", "maxRuntimeFiles", "maxDurationMs", "maxProtocolBytes",
28
+ "maxStderrBytes", "chunkBytes", "maxReportBytes", "maxAddressSpaceBytes",
29
+ "maxMetadataBytes", "maxKeyValues", "maxArrayElements", "maxDecodedCoordinates", "maxDecodeArithmeticUnits"}
30
+
31
+
32
+ def need(ok, message):
33
+ if not ok:
34
+ raise ValueError(message)
35
+
36
+
37
+ def fields(value, required, optional=()):
38
+ need(type(value) is dict and set(required) <= value.keys() <= set(required) | set(optional), "Unknown/missing reader fields")
39
+
40
+
41
+ def pairs(items):
42
+ result = {}
43
+ for key, value in items:
44
+ need(key not in result, "Duplicate JSON key")
45
+ result[key] = value
46
+ return result
47
+
48
+
49
+ def parse(raw):
50
+ return json.loads(raw, object_pairs_hook=pairs, parse_constant=lambda _: (_ for _ in ()).throw(ValueError("Nonfinite JSON")),
51
+ parse_int=lambda text: -0.0 if text == "-0" else int(text))
52
+
53
+
54
+ def encoded(value):
55
+ return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":"), allow_nan=False).encode()
56
+
57
+
58
+ def integer(value, minimum=0, maximum=9007199254740991):
59
+ need(type(value) is int and minimum <= value <= maximum, "Invalid reader integer")
60
+ return value
61
+
62
+
63
+ def regular(path):
64
+ path = Path(path)
65
+ info = path.lstat()
66
+ 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")
67
+ return info
68
+
69
+
70
+ def identity(info):
71
+ return (info.st_dev, info.st_ino, info.st_size, info.st_mtime_ns, info.st_ctime_ns)
72
+
73
+
74
+ class Budget:
75
+ def __init__(self, limits):
76
+ fields(limits, LIMITS)
77
+ for value in limits.values():
78
+ integer(value, 1)
79
+ need(limits["maxProtocolBytes"] <= 16 * 1024 ** 2 and limits["maxStderrBytes"] <= 1024 ** 2 and
80
+ 4096 <= limits["chunkBytes"] <= 4 * 1024 ** 2 and limits["chunkBytes"] % 4 == 0 and
81
+ limits["maxDurationMs"] <= 86400000, "Unsupported reader limits")
82
+ self.limits, self.started = limits, time.monotonic()
83
+ self.read_bytes = self.working = self.runtime_bytes = self.runtime_files = 0
84
+ self.input = self.artifacts = self.arithmetic = 0
85
+ self.stamps = {}
86
+ self.directories = {}
87
+ need(limits["maxMetadataBytes"] <= 256 * 1024 ** 2 and limits["maxKeyValues"] <= 100000 and limits["maxArrayElements"] <= 10000000, "GGUF metadata bounds exceeded")
88
+ self.reserve(limits["chunkBytes"] * 3 + limits["maxProtocolBytes"] * 2)
89
+
90
+ def check(self):
91
+ need(time.monotonic() - self.started <= self.limits["maxDurationMs"] / 1000, "Reader wall-clock budget exceeded")
92
+
93
+ def read(self, count):
94
+ self.check()
95
+ self.read_bytes += integer(count)
96
+ need(self.read_bytes <= self.limits["maxReadBytes"], "Reader logical-read byte budget exceeded")
97
+
98
+ def reserve(self, count):
99
+ self.check()
100
+ self.working += integer(count)
101
+ need(self.working <= self.limits["maxWorkingBytes"], "Reader working-byte budget exceeded")
102
+
103
+ def guard(self):
104
+ self.check()
105
+ for path, stamp in self.stamps.items():
106
+ need(identity(regular(path)) == stamp, "Reader source/runtime/checkpoint changed")
107
+ for path, stamp in self.directories.items():
108
+ info = Path(path).lstat()
109
+ need(stat.S_ISDIR(info.st_mode) and not Path(path).is_symlink() and identity(info) == stamp, "Reader checkpoint directory inventory changed")
110
+
111
+
112
+ def hash_file(path, budget, maximum=None):
113
+ path = Path(path)
114
+ before = regular(path)
115
+ need(maximum is None or before.st_size <= maximum, "Reader file exceeds declared bound")
116
+ budget.read(before.st_size)
117
+ result, size = hashlib.sha256(), 0
118
+ with path.open("rb") as stream:
119
+ need(identity(os.fstat(stream.fileno())) == identity(before), "Reader file changed while opening")
120
+ while True:
121
+ budget.check()
122
+ block = stream.read(budget.limits["chunkBytes"])
123
+ if not block:
124
+ break
125
+ size += len(block)
126
+ need(size <= before.st_size, "Reader file grew")
127
+ result.update(block)
128
+ need(identity(os.fstat(stream.fileno())) == identity(before), "Reader file changed while hashing")
129
+ need(size == before.st_size and identity(regular(path)) == identity(before), "Reader file extent/identity changed")
130
+ budget.stamps[str(path)] = identity(before)
131
+ return {"sha256": result.hexdigest(), "sizeBytes": size}
132
+
133
+
134
+ def read_range(path, offset, count, budget):
135
+ info = regular(path)
136
+ integer(offset)
137
+ integer(count)
138
+ need(offset + count <= info.st_size, "Reader range escaped actual source")
139
+ budget.read(count)
140
+ with Path(path).open("rb") as stream:
141
+ need(identity(os.fstat(stream.fileno())) == identity(info), "Reader range source changed")
142
+ stream.seek(offset)
143
+ raw = stream.read(count)
144
+ need(len(raw) == count and identity(os.fstat(stream.fileno())) == identity(info), "Reader range truncated/changed")
145
+ return raw
146
+
147
+
148
+ def cpu_guard(allow_codecs=False):
149
+ 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")
150
+ 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")
151
+ need(sys.byteorder == "little", "Only little-endian CPU storage is supported")
152
+ if not allow_codecs:
153
+ need("numpy" not in sys.modules and "gguf" not in sys.modules, "Codecs imported before full runtime admission")
154
+
155
+
156
+ def bootstrap(budget):
157
+ # -I alone still processes site .pth files. -S keeps their arbitrary startup
158
+ # code inert; append only this explicit venv's canonical package directory.
159
+ need(sys.flags.isolated == 1 and sys.flags.no_site == 1, "Reader requires isolated no-site Python startup")
160
+ executable = Path(os.path.abspath(sys.executable))
161
+ root = executable.parent.parent
162
+ config = root / "pyvenv.cfg"
163
+ config_hash = hash_file(config, budget, 65536)
164
+ site = root / "lib" / ("python%d.%d" % sys.version_info[:2]) / "site-packages"
165
+ info = site.lstat()
166
+ need(stat.S_ISDIR(info.st_mode) and not site.is_symlink() and site.resolve(strict=True) == site, "Explicit canonical venv site-packages required")
167
+ need(str(site) not in sys.path, "Venv packages unexpectedly active before admission")
168
+ sys.path.append(str(site))
169
+ return {"policy": "isolated_no_site_processing", "venvConfig": config_hash,
170
+ "sitePackagesPathDigest": hashlib.sha256(str(site).encode()).hexdigest()}
171
+
172
+
173
+ def load_editor(payload, budget):
174
+ cpu_guard()
175
+ own = hash_file(Path(__file__).resolve(strict=True), budget)
176
+ need(own["sha256"] == payload["expectedReaderSha256"], "Reader source pin mismatch")
177
+ path = Path(payload["checkpointEditorPath"])
178
+ source = hash_file(path, budget)
179
+ need(source["sha256"] == payload["expectedCheckpointEditorSha256"] == EDITOR_SHA, "Exact GGUF Scanner source pin mismatch")
180
+ spec = importlib.util.spec_from_file_location("nol_pinned_gguf_admission", path)
181
+ need(spec is not None and spec.loader is not None, "Pinned editor import unavailable")
182
+ editor = importlib.util.module_from_spec(spec)
183
+ # This pinned module is stdlib-only at import. Never register it as a
184
+ # substitutable package or execute its __main__ edit/publish entry point.
185
+ spec.loader.exec_module(editor)
186
+ cpu_guard()
187
+ original = editor.hash_file
188
+
189
+ def tracked_hash(path, original_budget=None):
190
+ budget.read(regular(path).st_size)
191
+ return original(path, original_budget)
192
+
193
+ editor.hash_file = tracked_hash
194
+ return editor, own, source, bootstrap(budget)
195
+
196
+
197
+ def runtime_inventory(payload, budget, own, editor_source, python_environment):
198
+ packages, names = [], set()
199
+ for distribution in sorted(importlib.metadata.distributions(), key=lambda d: d.metadata.get("Name", "").lower()):
200
+ budget.check()
201
+ name = distribution.metadata.get("Name", "")
202
+ if not name:
203
+ continue
204
+ need(name.lower() not in names, "Ambiguous duplicate installed distribution")
205
+ names.add(name.lower())
206
+ paths = {}
207
+ metadata = Path(distribution._path)
208
+ record = metadata / "RECORD"
209
+ record_size = regular(record).st_size
210
+ need(record_size <= min(budget.limits["maxProtocolBytes"] * 4, 16 * 1024 ** 2), "Runtime RECORD allocation cap exceeded")
211
+ budget.reserve(record_size * 8)
212
+ hash_file(record, budget)
213
+ budget.read(record_size) # importlib.metadata's bounded CSV projection.
214
+ for item in distribution.files or ():
215
+ text = str(item)
216
+ if CODE.search(text) and "__pycache__" not in text:
217
+ paths[text] = Path(os.path.abspath(distribution.locate_file(item)))
218
+ need(len(paths) <= budget.limits["maxRuntimeFiles"], "Runtime file enumeration cap exceeded")
219
+ # Codecs are checked against the complete actual package trees, not
220
+ # merely a potentially incomplete RECORD file. Bundled libraries and
221
+ # all distribution metadata are included before any codec import.
222
+ if name.lower() in ("numpy", "gguf"):
223
+ base = Path(distribution.locate_file(""))
224
+ package = base / name.lower()
225
+ spec = importlib.util.find_spec(name.lower())
226
+ need(spec is not None and spec.origin == str(package / "__init__.py") and list(spec.submodule_search_locations or ()) == [str(package)], "Codec import origin differs from pinned package")
227
+ candidates = [package, base / (name.lower() + ".libs"), Path(distribution._path)]
228
+ for top in candidates:
229
+ if not top.exists():
230
+ continue
231
+ pending = [top]
232
+ while pending:
233
+ directory = pending.pop(); budget.check()
234
+ info = directory.lstat()
235
+ need(stat.S_ISDIR(info.st_mode) and not directory.is_symlink(), "Runtime package directory symlink refused")
236
+ budget.directories[str(directory)] = identity(info)
237
+ with os.scandir(directory) as children:
238
+ for child in children:
239
+ budget.check()
240
+ need(not child.is_symlink(), "Runtime package symlink refused")
241
+ if child.name == "__pycache__" or child.name.endswith((".pyc", ".pyo")):
242
+ continue
243
+ path = Path(child.path)
244
+ if child.is_dir(follow_symlinks=False):
245
+ pending.append(path)
246
+ else:
247
+ need(child.is_file(follow_symlinks=False), "Runtime special file refused")
248
+ paths[path.relative_to(base).as_posix()] = path
249
+ need(len(paths) + len(pending) <= budget.limits["maxRuntimeFiles"], "Complete runtime tree enumeration cap exceeded")
250
+ entries, total = [], 0
251
+ for text, path in sorted(paths.items()):
252
+ budget.check()
253
+ info = regular(path)
254
+ budget.runtime_bytes += info.st_size; budget.runtime_files += 1
255
+ need(budget.runtime_bytes <= budget.limits["maxRuntimeBytes"] and budget.runtime_files <= budget.limits["maxRuntimeFiles"], "Reader runtime inventory budget exceeded")
256
+ budget.reserve(512 + len(text.encode()))
257
+ actual = hash_file(path, budget); total += actual["sizeBytes"]
258
+ entries.append({"path": text, **actual})
259
+ packages.append({"name": name, "version": distribution.version, "files": len(entries), "bytes": total, "digest": hashlib.sha256(encoded(entries)).hexdigest()})
260
+ need(any(p["name"].lower() == "numpy" for p in packages) and any(p["name"].lower() == "gguf" for p in packages), "Explicit NumPy/GGUF codec environment unavailable")
261
+ need(importlib.metadata.version("gguf") == "0.19.0", "Unreviewed GGUF codec version")
262
+ body = {"schema": "omnius.nol.gguf-control-reader-runtime.v1", "pythonVersion": sys.version.split()[0],
263
+ "pythonExecutable": hash_file(Path(sys.executable).resolve(strict=True), budget), "packages": packages,
264
+ "reader": own, "checkpointEditor": editor_source, "dependencyLock": hash_file(Path(payload["dependencyLockPath"]), budget, 1024 ** 2), "pythonEnvironment": python_environment}
265
+ cpu_guard()
266
+ return {**body, "runtimeDigest": hashlib.sha256(encoded(body)).hexdigest()}
267
+
268
+
269
+ # Independent host uses the same wire specification, not NumPy/gguf dequantize.
270
+ BLOCKS = {"F32": (0, 1, 4), "F16": (1, 1, 2), "BF16": (30, 1, 2), "Q8_0": (8, 32, 34),
271
+ "Q4_0": (2, 32, 18), "Q4_K": (12, 256, 144), "Q6_K": (14, 256, 210)}
272
+
273
+
274
+ def storage_class(name, shape):
275
+ need(type(name) is str and len(shape) in (1, 2), "Unknown/packed GGUF tensor rank")
276
+ if name in ("token_embd.weight", "position_embd.weight", "output.weight"):
277
+ need(len(shape) == 2, "Embedding/output storage must be a matrix")
278
+ return "ordinary_matrix_storage_only"
279
+ if name in ("output_norm.weight", "token_embd_norm.weight", "rope_freqs.weight", "output.bias") or re.fullmatch(r"blk\.\d+\.(attn_norm|ffn_norm|post_attention_norm|attn_q_norm|attn_k_norm|ssm_norm)\.weight", name):
280
+ need(len(shape) == 1, "Norm/vector storage must be a vector")
281
+ return "ordinary_vector_storage_only"
282
+ if name in ("output_scale", "logit_scale"):
283
+ need(shape == [1], "Scalar storage must have one element")
284
+ return "ordinary_scalar_storage_only"
285
+ if re.fullmatch(r"blk\.\d+\.(ffn_(up|gate|down)|attn_(q|k|v|qkv|output|gate)|ssm_(alpha|beta|out|conv1d))\.weight", name):
286
+ need(len(shape) == 2, "Known dense/recurrent storage must be a matrix")
287
+ return "ordinary_matrix_storage_only"
288
+ if re.fullmatch(r"blk\.\d+\.(ffn_(up|gate|down)|attn_(q|k|v|qkv|output|gate)|ssm_dt)\.bias", name) or re.fullmatch(r"blk\.\d+\.ssm_a", name):
289
+ need(len(shape) == 1, "Known bias/recurrent storage must be a vector")
290
+ return "ordinary_vector_storage_only"
291
+ raise ValueError("Unknown/expert/router/packed GGUF storage name; semantics are not inferred")
292
+
293
+
294
+ def inventory(payload, editor, runtime, budget):
295
+ model, root = payload["model"], Path(payload["checkpointRoot"])
296
+ need(root.is_absolute() and root.resolve(strict=True) == root and not root.is_symlink(), "Canonical checkpoint root required")
297
+ need(model.get("format") == "gguf", "Only explicit single-file GGUF supported")
298
+ files = model["files"]
299
+ need(type(files) is list and 0 < len(files) <= 100000, "Bounded model source inventory required")
300
+ weights = [f for f in files if f["role"] == "weights"]
301
+ need(len(weights) == 1 and weights[0]["path"].endswith(".gguf") and sum(f["path"].endswith(".gguf") for f in files) == 1, "Split/mixed/compressed GGUF checkpoints unsupported")
302
+ total = sum(integer(f["artifact"]["sizeBytes"]) for f in files)
303
+ need(total <= budget.limits["maxInputBytes"], "Reader aggregate model input cap exceeded")
304
+ identity_body = payload["identity"]
305
+ fields(identity_body, ("modelJson", "tensorSitesJson"))
306
+ body = {key: value for key, value in model.items() if key not in ("id", "modelDigest")}
307
+ need(hashlib.sha256(identity_body["modelJson"].encode()).hexdigest() == model["modelDigest"] and editor.same(parse(identity_body["modelJson"]), body), "Frozen complete model identity mismatch")
308
+ need(hashlib.sha256(identity_body["tensorSitesJson"].encode()).hexdigest() == model["architectureMapDigest"] and editor.same(parse(identity_body["tensorSitesJson"]), model["tensorSites"]), "Frozen tensor-map identity mismatch")
309
+ expected = {file["path"] for file in files}
310
+ need(len(expected) == len(files), "Duplicate source path")
311
+ directories, actual = [root], set()
312
+ while directories:
313
+ directory = directories.pop(); budget.check()
314
+ info = directory.lstat()
315
+ need(stat.S_ISDIR(info.st_mode) and not directory.is_symlink(), "Checkpoint directory symlink unsupported")
316
+ budget.directories[str(directory)] = identity(info)
317
+ need(len(budget.directories) <= len(expected) * 2 + 32, "Directory scan bound exceeded")
318
+ with os.scandir(directory) as entries:
319
+ for entry in entries:
320
+ budget.check(); need(not entry.is_symlink(), "Checkpoint symlink unsupported")
321
+ path = Path(entry.path)
322
+ if entry.is_dir(follow_symlinks=False): directories.append(path)
323
+ else:
324
+ need(entry.is_file(follow_symlinks=False), "Special checkpoint file refused")
325
+ actual.add(path.relative_to(root).as_posix())
326
+ need(len(actual) <= len(expected), "Complete source directory inventory exceeded")
327
+ need(actual == expected, "Complete source directory differs from frozen model")
328
+ facts = []
329
+ for file in files:
330
+ value = hash_file(editor.safe(root, file["path"]), budget)
331
+ need(value == {"sha256": file["artifact"]["sha256"], "sizeBytes": file["artifact"]["sizeBytes"]}, "Complete source file hash mismatch")
332
+ facts.append({"path": file["path"], "role": file["role"], **value})
333
+ # Recompute the complete code/runtime/lock inventory before the first
334
+ # Scanner import of NumPy/GGUF. No codecs or neural framework ran above.
335
+ actual_runtime = runtime()
336
+ need(editor.same(actual_runtime, payload["runtime"]), "Pinned reader runtime changed before codecs")
337
+ cpu_guard()
338
+ class TrackedScanner(editor.Scanner):
339
+ def read(self, size):
340
+ budget.read(size)
341
+ return super().read(size)
342
+ path = editor.safe(root, weights[0]["path"])
343
+ allocation_bound = min(regular(path).st_size, budget.limits["maxMetadataBytes"]) * 4 + budget.limits["maxArrayElements"] * 1024 + budget.limits["maxTensors"] * 2048
344
+ need(budget.working + allocation_bound <= budget.limits["maxWorkingBytes"], "GGUF metadata allocation bound exceeded before codec/Scanner import")
345
+ scanned = TrackedScanner(path, budget)
346
+ need(len(scanned.tensors) <= budget.limits["maxTensors"], "Tensor inventory bound exceeded")
347
+ for key, (_, value) in scanned.keys.items():
348
+ if "expert" in key.lower() or "router" in key.lower():
349
+ need(value == 0 and type(value) in (int, bool), "Expert/router metadata requires a separate packed-storage protocol")
350
+ architecture = scanned.keys["general.architecture"][1]
351
+ need("moe" not in architecture.lower(), "MoE packed architecture is not admitted by this reader")
352
+ # Scanner is complete and rejects split metadata, duplicates, malformed
353
+ # arrays, unknown quantization IDs, aliases, overlaps and truncated ranges.
354
+ editor.verify_official(path, scanned, budget)
355
+ cpu_guard(True)
356
+ coordinates, tensors = 0, []
357
+ mapped = {s["name"]: s for s in model["tensorSites"] if s["kind"] == "parameter"}
358
+ for tensor in scanned.tensors:
359
+ budget.check()
360
+ kind = tensor["qtype"]
361
+ need(kind in BLOCKS, "Unsupported/unknown physical storage codec")
362
+ type_id, block, width = BLOCKS[kind]
363
+ need(tensor["typeId"] == type_id and tensor["ne"][0] % block == 0, "Actual codec block identity changed")
364
+ classification = storage_class(tensor["name"], tensor["shape"])
365
+ if tensor["name"] in mapped:
366
+ site = mapped[tensor["name"]]
367
+ need(site["shape"] == tensor["shape"] and site["dtype"] == editor.logical_dtype(kind), "Declared parameter map differs from storage")
368
+ coordinates += tensor["elements"]
369
+ need(coordinates <= budget.limits["maxCoordinates"], "Tensor coordinate inventory cap exceeded")
370
+ size, start = tensor["sizeBytes"], tensor["dataOffset"]
371
+ sha = hashlib.sha256()
372
+ for offset in range(0, size, budget.limits["chunkBytes"]):
373
+ sha.update(read_range(path, start + offset, min(budget.limits["chunkBytes"], size - offset), budget))
374
+ tensors.append({"name": tensor["name"], "shape": tensor["shape"], "ggmlDimensions": tensor["ne"], "qtype": kind,
375
+ "typeId": type_id, "sourceFile": weights[0]["path"], "dataOffsetBytes": start, "sizeBytes": size,
376
+ "sha256": sha.hexdigest(), "elements": tensor["elements"], "storageClass": classification,
377
+ "block": {"elements": block, "bytes": width, "rowElements": tensor["ne"][0],
378
+ "rowBytes": tensor["ne"][0] // block * width, "blocks": tensor["elements"] // block},
379
+ "decoding": "independent_host_supported" if kind in ("F32", "F16", "BF16", "Q8_0") else "opaque_only"})
380
+ need(set(mapped) <= set(scanned.byName), "Declared parameter is missing from actual GGUF")
381
+ for file in files:
382
+ need(hash_file(editor.safe(root, file["path"]), budget) == {"sha256": file["artifact"]["sha256"], "sizeBytes": file["artifact"]["sizeBytes"]}, "Source changed after inventory")
383
+ metadata_hash = hashlib.sha256()
384
+ for offset in range(0, scanned.dataStart, budget.limits["chunkBytes"]):
385
+ metadata_hash.update(read_range(path, offset, min(budget.limits["chunkBytes"], scanned.dataStart - offset), budget))
386
+ metadata = metadata_hash.hexdigest()
387
+ budget.guard()
388
+ return {"schema": "omnius.nol.gguf-control-inventory.v1", "modelDigest": model["modelDigest"],
389
+ "runtimeDigest": actual_runtime["runtimeDigest"], "readerSha256": actual_runtime["reader"]["sha256"],
390
+ "checkpointEditorSha256": EDITOR_SHA, "files": facts, "tensors": sorted(tensors, key=lambda t: t["name"]),
391
+ "version": 3, "alignment": scanned.alignment, "dataStartBytes": scanned.dataStart, "metadataSha256": metadata,
392
+ "usage": {"inputBytes": total, "logicalReadBytes": budget.read_bytes, "reservedWorkingBytes": budget.working},
393
+ "officialReaderVerified": True, "codecsImportedAfterFullRuntimeAdmission": True, "device": "cpu",
394
+ "cudaInitialized": False, "modelConstructed": False, "numericalControlVerified": False, "authority": "none"}
395
+
396
+
397
+ def main():
398
+ raw = sys.stdin.buffer.read(16 * 1024 ** 2 + 1)
399
+ need(len(raw) <= 16 * 1024 ** 2, "Absolute reader request cap exceeded")
400
+ payload = parse(raw)
401
+ fields(payload, ("schema", "action", "expectedReaderSha256", "checkpointEditorPath", "expectedCheckpointEditorSha256", "dependencyLockPath", "limits"),
402
+ ("runtime", "model", "checkpointRoot", "identity"))
403
+ need(payload["schema"] == SCHEMA and payload["action"] in ("inspect", "inventory"), "Unsupported reader action/schema")
404
+ budget = Budget(payload["limits"])
405
+ need(len(raw) <= budget.limits["maxProtocolBytes"], "Reader request protocol cap exceeded")
406
+ resource.setrlimit(resource.RLIMIT_AS, (budget.limits["maxAddressSpaceBytes"], budget.limits["maxAddressSpaceBytes"]))
407
+ resource.setrlimit(resource.RLIMIT_CPU, (max(1, math.ceil(budget.limits["maxDurationMs"] / 1000)), max(2, math.ceil(budget.limits["maxDurationMs"] / 1000) + 1)))
408
+ editor, own, source, python_environment = load_editor(payload, budget)
409
+ runtime = lambda: runtime_inventory(payload, budget, own, source, python_environment)
410
+ if payload["action"] == "inspect":
411
+ need(not any(key in payload for key in ("runtime", "model", "checkpointRoot", "identity")), "Inspect cannot accept checkpoint/model input")
412
+ result = {"runtime": runtime(), "codecsImported": False, "torchImported": False, "cudaInitialized": False, "modelConstructed": False}
413
+ budget.guard()
414
+ else:
415
+ need(all(key in payload for key in ("runtime", "model", "checkpointRoot", "identity")), "Frozen runtime/model input required")
416
+ result = inventory(payload, editor, runtime, budget)
417
+ raw = encoded(result)
418
+ need(len(raw) <= budget.limits["maxProtocolBytes"], "Reader response protocol cap exceeded")
419
+ sys.stdout.buffer.write(raw); sys.stdout.flush()
420
+
421
+
422
+ if __name__ == "__main__":
423
+ try:
424
+ signal.signal(signal.SIGTERM, lambda *_: (_ for _ in ()).throw(InterruptedError("CPU reader Stop")))
425
+ main()
426
+ except BaseException as error:
427
+ sys.stderr.write((type(error).__name__ + ": " + str(error))[-4000:] + "; codecsImported=" + str("numpy" in sys.modules or "gguf" in sys.modules).lower() + "; torchImported=" + str("torch" in sys.modules).lower() + "\n")
428
+ sys.exit(1)