vayrm 0.1.0__py3-none-any.whl
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.
- acr/__init__.py +29 -0
- acr/api/__init__.py +0 -0
- acr/api/root_api.py +87 -0
- acr/api/server.py +70 -0
- acr/cache/__init__.py +20 -0
- acr/cache/manager.py +394 -0
- acr/cache/policy.py +187 -0
- acr/checkpoint/__init__.py +30 -0
- acr/checkpoint/delta.py +209 -0
- acr/checkpoint/manager.py +764 -0
- acr/checkpoint/manifest.py +174 -0
- acr/checkpoint/policy.py +181 -0
- acr/checkpoint/provider.py +44 -0
- acr/cli.py +74 -0
- acr/cluster/__init__.py +20 -0
- acr/cluster/eligibility.py +71 -0
- acr/cluster/federation.py +77 -0
- acr/cluster/knowledge.py +285 -0
- acr/cluster/node_entry.py +103 -0
- acr/cluster/root_brain.py +1090 -0
- acr/cluster/state_aggregator.py +340 -0
- acr/cluster/subroot_agent.py +234 -0
- acr/communication/__init__.py +0 -0
- acr/communication/checkpoint_transfer.py +237 -0
- acr/communication/framing.py +182 -0
- acr/communication/inmemory.py +274 -0
- acr/communication/interfaces.py +173 -0
- acr/communication/local_channel.py +68 -0
- acr/communication/network.py +193 -0
- acr/communication/paladin_adapter.py +1003 -0
- acr/communication/priority.py +45 -0
- acr/communication/propagation.py +98 -0
- acr/communication/protocol.py +1349 -0
- acr/communication/tcp.py +917 -0
- acr/communication/transport.py +286 -0
- acr/core/__init__.py +3 -0
- acr/core/config.py +134 -0
- acr/core/enums.py +87 -0
- acr/core/errors.py +15 -0
- acr/core/identity.py +63 -0
- acr/core/types.py +6 -0
- acr/entrypoint.py +691 -0
- acr/events.py +600 -0
- acr/execution/__init__.py +5 -0
- acr/execution/dispatcher.py +63 -0
- acr/execution/feedback.py +79 -0
- acr/execution/manager.py +126 -0
- acr/execution/models.py +102 -0
- acr/execution/safe_worker.py +145 -0
- acr/facade.py +142 -0
- acr/history/__init__.py +3 -0
- acr/history/execution.py +85 -0
- acr/integration/__init__.py +0 -0
- acr/integration/paladin_import.py +72 -0
- acr/logging.py +78 -0
- acr/migration/__init__.py +3 -0
- acr/migration/manager.py +110 -0
- acr/network/__init__.py +0 -0
- acr/network/paladin_adapter.py +359 -0
- acr/node/__init__.py +72 -0
- acr/node/agent.py +483 -0
- acr/node/assessment.py +388 -0
- acr/node/brain.py +812 -0
- acr/node/history.py +95 -0
- acr/node/knowledge.py +680 -0
- acr/node/peer_view.py +226 -0
- acr/node/resource_snapshot.py +294 -0
- acr/node/self_model.py +542 -0
- acr/node/state_buffer.py +145 -0
- acr/node/state_machine.py +384 -0
- acr/node/state_publisher.py +245 -0
- acr/node/temporal.py +399 -0
- acr/peers/__init__.py +36 -0
- acr/peers/interfaces.py +65 -0
- acr/peers/knowledge.py +212 -0
- acr/peers/manager.py +186 -0
- acr/peers/merge.py +94 -0
- acr/peers/models.py +227 -0
- acr/platforms/__init__.py +8 -0
- acr/platforms/linux/__init__.py +12 -0
- acr/platforms/linux/provider.py +10 -0
- acr/platforms/linux/runtime.py +85 -0
- acr/platforms/linux/workloads.py +22 -0
- acr/platforms/macos/__init__.py +12 -0
- acr/platforms/macos/provider.py +10 -0
- acr/platforms/macos/runtime.py +28 -0
- acr/platforms/macos/workloads.py +24 -0
- acr/platforms/windows/__init__.py +12 -0
- acr/platforms/windows/provider.py +10 -0
- acr/platforms/windows/runtime.py +28 -0
- acr/platforms/windows/workloads.py +20 -0
- acr/registry/__init__.py +20 -0
- acr/registry/backend.py +63 -0
- acr/registry/cluster_registry.py +105 -0
- acr/registry/node_registry.py +41 -0
- acr/registry/resource_registry.py +395 -0
- acr/registry/root_registry.py +57 -0
- acr/registry/session_registry.py +74 -0
- acr/registry/subroot_registry.py +162 -0
- acr/resource_fabric/__init__.py +55 -0
- acr/resource_fabric/capacity_model.py +165 -0
- acr/resource_fabric/cooldown.py +133 -0
- acr/resource_fabric/criticality.py +57 -0
- acr/resource_fabric/decision_engine.py +476 -0
- acr/resource_fabric/filtering.py +220 -0
- acr/resource_fabric/hardware.py +182 -0
- acr/resource_fabric/hierarchy.py +229 -0
- acr/resource_fabric/manager.py +505 -0
- acr/resource_fabric/normalization.py +70 -0
- acr/resource_fabric/preemption.py +393 -0
- acr/resource_fabric/quota.py +132 -0
- acr/resource_fabric/reconciliation.py +160 -0
- acr/resource_fabric/resource_claim.py +184 -0
- acr/resource_fabric/resource_health.py +75 -0
- acr/resource_fabric/resource_lease.py +147 -0
- acr/resource_fabric/resource_offer.py +126 -0
- acr/resource_fabric/resource_policy.py +164 -0
- acr/resource_fabric/resource_pool.py +375 -0
- acr/resource_fabric/scoring.py +329 -0
- acr/resources/__init__.py +3 -0
- acr/resources/capabilities.py +111 -0
- acr/resources/cluster_state.py +101 -0
- acr/resources/metric.py +15 -0
- acr/resources/node_context.py +250 -0
- acr/resources/pressure.py +47 -0
- acr/resources/snapshot.py +173 -0
- acr/resources/state.py +139 -0
- acr/runtime/__init__.py +0 -0
- acr/runtime/aggregate_state.py +102 -0
- acr/runtime/continuous_sampler.py +103 -0
- acr/runtime/discovery.py +199 -0
- acr/runtime/endpoint.py +81 -0
- acr/runtime/master_root.py +154 -0
- acr/runtime/monitoring.py +205 -0
- acr/runtime/monte_carlo.py +139 -0
- acr/runtime/node.py +74 -0
- acr/runtime/node_brain.py +242 -0
- acr/runtime/node_model.py +104 -0
- acr/runtime/policy.py +179 -0
- acr/runtime/root.py +44 -0
- acr/runtime/root_controller.py +250 -0
- acr/runtime/safety.py +81 -0
- acr/runtime/scheduling_view.py +325 -0
- acr/runtime/trajectory.py +67 -0
- acr/runtime/workload_brain.py +136 -0
- acr/schedulers/__init__.py +54 -0
- acr/schedulers/adaptive.py +333 -0
- acr/schedulers/adaptive_common.py +44 -0
- acr/schedulers/adaptive_v2.py +94 -0
- acr/schedulers/adaptive_v3.py +387 -0
- acr/schedulers/admission.py +76 -0
- acr/schedulers/base.py +83 -0
- acr/schedulers/context.py +44 -0
- acr/schedulers/decision.py +85 -0
- acr/schedulers/estimation.py +141 -0
- acr/schedulers/explainable.py +129 -0
- acr/schedulers/heterogeneity.py +251 -0
- acr/schedulers/heterogeneity_aware.py +316 -0
- acr/schedulers/least_loaded.py +182 -0
- acr/schedulers/monte_carlo.py +123 -0
- acr/schedulers/queue.py +132 -0
- acr/schedulers/reasons.py +68 -0
- acr/schedulers/replay.py +41 -0
- acr/schedulers/resource_aware.py +547 -0
- acr/schedulers/round_robin.py +77 -0
- acr/schedulers/state_aware.py +144 -0
- acr/schedulers/strategy.py +310 -0
- acr/schedulers/task_weights.py +87 -0
- acr/schedulers/trace.py +284 -0
- acr/schedulers/weights.py +79 -0
- acr/scripts/__init__.py +0 -0
- acr/scripts/live_validator.py +0 -0
- acr/simulation/__init__.py +8 -0
- acr/simulation/decentralized.py +294 -0
- acr/simulation/failure_injector.py +0 -0
- acr/state/__init__.py +45 -0
- acr/state/catalog.py +284 -0
- acr/state/chunk.py +186 -0
- acr/state/manifest.py +239 -0
- acr/state/object.py +252 -0
- acr/state/residency.py +282 -0
- acr/storage/__init__.py +19 -0
- acr/storage/backend.py +115 -0
- acr/storage/filesystem.py +127 -0
- acr/storage/memory.py +78 -0
- acr/subroot/__init__.py +7 -0
- acr/subroot/local_fabric.py +180 -0
- acr/subroot/runtime.py +225 -0
- acr/telemetry/__init__.py +3 -0
- acr/telemetry/__main__.py +93 -0
- acr/telemetry/base.py +25 -0
- acr/telemetry/collector.py +94 -0
- acr/telemetry/detector.py +45 -0
- acr/telemetry/platforms/__init__.py +3 -0
- acr/telemetry/platforms/linux/__init__.py +3 -0
- acr/telemetry/platforms/linux/cpu.py +184 -0
- acr/telemetry/platforms/linux/gpu.py +161 -0
- acr/telemetry/platforms/linux/memory.py +149 -0
- acr/telemetry/platforms/linux/network.py +170 -0
- acr/telemetry/platforms/linux/power.py +52 -0
- acr/telemetry/platforms/linux/provider.py +133 -0
- acr/telemetry/platforms/linux/storage.py +98 -0
- acr/telemetry/platforms/linux/system.py +30 -0
- acr/telemetry/platforms/linux/thermal.py +106 -0
- acr/telemetry/platforms/macos/__init__.py +3 -0
- acr/telemetry/platforms/macos/cpu.py +85 -0
- acr/telemetry/platforms/macos/gpu.py +208 -0
- acr/telemetry/platforms/macos/memory.py +61 -0
- acr/telemetry/platforms/macos/network.py +32 -0
- acr/telemetry/platforms/macos/power.py +44 -0
- acr/telemetry/platforms/macos/provider.py +75 -0
- acr/telemetry/platforms/macos/storage.py +33 -0
- acr/telemetry/platforms/macos/system.py +16 -0
- acr/telemetry/platforms/macos/thermal.py +59 -0
- acr/telemetry/platforms/windows/__init__.py +3 -0
- acr/telemetry/platforms/windows/cpu.py +86 -0
- acr/telemetry/platforms/windows/gpu.py +449 -0
- acr/telemetry/platforms/windows/memory.py +69 -0
- acr/telemetry/platforms/windows/network.py +86 -0
- acr/telemetry/platforms/windows/power.py +68 -0
- acr/telemetry/platforms/windows/provider.py +74 -0
- acr/telemetry/platforms/windows/storage.py +62 -0
- acr/telemetry/platforms/windows/system.py +13 -0
- acr/telemetry/platforms/windows/thermal.py +139 -0
- acr/telemetry/record.py +232 -0
- acr/telemetry/root_telemetry_tracker.py +422 -0
- acr/telemetry/validate.py +98 -0
- acr/test_bug.py +6 -0
- acr/test_migration.py +81 -0
- acr/test_node.py +6 -0
- acr/test_provider.py +10 -0
- acr/training/__init__.py +0 -0
- acr/training/backend.py +87 -0
- acr/training/worker.py +48 -0
- acr/transfer/__init__.py +51 -0
- acr/transfer/backend.py +154 -0
- acr/transfer/backends/__init__.py +3 -0
- acr/transfer/backends/memory.py +239 -0
- acr/transfer/backends/tcp.py +396 -0
- acr/transfer/chunking.py +268 -0
- acr/transfer/diff.py +283 -0
- acr/transfer/manager.py +336 -0
- acr/transfer/plan.py +307 -0
- acr/ui/__init__.py +0 -0
- acr/ui/resource_dashboard.py +0 -0
- acr/ui/root_dashboard.py +1144 -0
- acr/utils/__init__.py +0 -0
- acr/utils/profiling.py +80 -0
- acr/workloads/__init__.py +15 -0
- acr/workloads/characteristics.py +36 -0
- acr/workloads/cpu_worker.py +60 -0
- acr/workloads/identity.py +36 -0
- acr/workloads/io_worker.py +86 -0
- acr/workloads/knowledge.py +36 -0
- acr/workloads/memory_worker.py +68 -0
- acr/workloads/mixed_worker.py +80 -0
- acr/workloads/profile.py +44 -0
- acr/workloads/pytorch/__init__.py +0 -0
- acr/workloads/pytorch/adapter.py +37 -0
- acr/workloads/pytorch/checkpoint.py +33 -0
- acr/workloads/pytorch/runtime.py +229 -0
- acr/workloads/requirements.py +155 -0
- acr/workloads/spec.py +39 -0
- acr/workloads/state_needs.py +32 -0
- acr/workloads/virtual.py +146 -0
- acr/workloads/windows_workloads.py +79 -0
- acr/workloads/worker.py +83 -0
- acr/workloads/workload.py +126 -0
- ai/__init__.py +0 -0
- ai/agents/__init__.py +0 -0
- ai/agents/agents.py +0 -0
- ai/checkpoints/__init__.py +0 -0
- ai/checkpoints/checkpoints.py +0 -0
- ai/datasets/__init__.py +0 -0
- ai/datasets/datasets.py +0 -0
- ai/fusion/__init__.py +0 -0
- ai/fusion/fusion.py +0 -0
- ai/inference/__init__.py +0 -0
- ai/inference/inference.py +0 -0
- ai/model_loader/__init__.py +0 -0
- ai/model_loader/model_loader.py +0 -0
- ai/model_registry/__init__.py +0 -0
- ai/model_registry/model_registry.py +0 -0
- ai/orchestration/__init__.py +0 -0
- ai/orchestration/orchestration.py +0 -0
- ai/plugins/__init__.py +0 -0
- ai/plugins/coding/__init__.py +0 -0
- ai/plugins/coding/coding.py +0 -0
- ai/plugins/embedding/__init__.py +0 -0
- ai/plugins/embedding/embedding.py +0 -0
- ai/plugins/llm/__init__.py +0 -0
- ai/plugins/llm/llm.py +0 -0
- ai/plugins/memory/__init__.py +0 -0
- ai/plugins/memory/memory.py +0 -0
- ai/plugins/ocr/__init__.py +0 -0
- ai/plugins/ocr/ocr.py +0 -0
- ai/plugins/planning/__init__.py +0 -0
- ai/plugins/planning/planning.py +0 -0
- ai/plugins/reranker/__init__.py +0 -0
- ai/plugins/reranker/reranker.py +0 -0
- ai/plugins/slm/__init__.py +0 -0
- ai/plugins/slm/slm.py +0 -0
- ai/plugins/speech/__init__.py +0 -0
- ai/plugins/speech/speech.py +0 -0
- ai/plugins/trm/__init__.py +0 -0
- ai/plugins/trm/trm.py +0 -0
- ai/plugins/vision/__init__.py +0 -0
- ai/plugins/vision/vision.py +0 -0
- ai/runtime/__init__.py +0 -0
- ai/runtime/runtime.py +0 -0
- ai/tensors/__init__.py +0 -0
- ai/tensors/tensors.py +0 -0
- ai/training/__init__.py +0 -0
- ai/training/training.py +0 -0
- ai/workflows/__init__.py +0 -0
- ai/workflows/workflows.py +0 -0
- apps/__init__.py +0 -0
- apps/cli/__init__.py +0 -0
- apps/cli/main.py +517 -0
- apps/node/__init__.py +0 -0
- apps/node/api.py +140 -0
- apps/node/main.py +634 -0
- apps/node/peers.py +224 -0
- apps/root/__init__.py +0 -0
- apps/root/api/__init__.py +0 -0
- apps/root/api/server.py +244 -0
- apps/root/main.py +809 -0
- cluster/__init__.py +0 -0
- cluster/allocation/__init__.py +0 -0
- cluster/allocation/allocation.py +0 -0
- cluster/autoscaling/__init__.py +0 -0
- cluster/autoscaling/autoscaling.py +0 -0
- cluster/balancer/__init__.py +0 -0
- cluster/balancer/balancer.py +0 -0
- cluster/failover/__init__.py +0 -0
- cluster/failover/failover.py +0 -0
- cluster/global_state/__init__.py +0 -0
- cluster/global_state/global_state.py +0 -0
- cluster/health/__init__.py +0 -0
- cluster/health/health.py +0 -0
- cluster/leader/__init__.py +0 -0
- cluster/leader/leader.py +0 -0
- cluster/membership/__init__.py +0 -0
- cluster/membership/membership.py +0 -0
- cluster/node_manager/__init__.py +0 -0
- cluster/node_manager/node_manager.py +0 -0
- cluster/placement/__init__.py +0 -0
- cluster/placement/placement.py +0 -0
- cluster/recovery/__init__.py +0 -0
- cluster/recovery/recovery.py +0 -0
- cluster/registry/__init__.py +0 -0
- cluster/registry/registry.py +0 -0
- cluster/replication/__init__.py +0 -0
- cluster/replication/replication.py +0 -0
- cluster/resource_manager/__init__.py +0 -0
- cluster/resource_manager/resource_manager.py +0 -0
- cluster/routing/__init__.py +0 -0
- cluster/routing/routing.py +0 -0
- cluster/scheduler/__init__.py +0 -0
- cluster/scheduler/scheduler.py +0 -0
- cluster/topology/__init__.py +0 -0
- cluster/topology/topology.py +0 -0
- core/__init__.py +0 -0
- core/ai/__init__.py +0 -0
- core/ai/agent.py +8 -0
- core/ai/cognition.py +9 -0
- core/ai/context.py +8 -0
- core/ai/dataset_security/__init__.py +9 -0
- core/ai/dataset_security/dataset.py +26 -0
- core/ai/execution.py +8 -0
- core/ai/registry/__init__.py +9 -0
- core/ai/registry/registry.py +40 -0
- core/ai/scheduler.py +9 -0
- core/bootstrap/__init__.py +50 -0
- core/bootstrap/docker.py +209 -0
- core/bootstrap/environment.py +50 -0
- core/bootstrap/headscale.py +177 -0
- core/bootstrap/manager.py +260 -0
- core/bootstrap/metrics.py +40 -0
- core/bootstrap/platform/__init__.py +68 -0
- core/bootstrap/platform/base.py +164 -0
- core/bootstrap/platform/capabilities.py +166 -0
- core/bootstrap/platform/linux.py +168 -0
- core/bootstrap/platform/macos.py +131 -0
- core/bootstrap/platform/service_manager.py +226 -0
- core/bootstrap/platform/windows.py +162 -0
- core/bootstrap/policies.py +5 -0
- core/bootstrap/ports.py +141 -0
- core/bootstrap/processes.py +138 -0
- core/bootstrap/recovery.py +29 -0
- core/bootstrap/sources.py +5 -0
- core/bootstrap/state_machine.py +86 -0
- core/bootstrap/tailscale.py +175 -0
- core/bootstrap/validators.py +5 -0
- core/capabilities/__init__.py +0 -0
- core/capabilities/descriptor.py +12 -0
- core/capabilities/graph/__init__.py +0 -0
- core/capabilities/graph/dependencies.py +15 -0
- core/capabilities/graph/graph.py +14 -0
- core/capabilities/graph/query.py +10 -0
- core/capabilities/manager.py +8 -0
- core/capabilities/registry.py +8 -0
- core/cluster/__init__.py +0 -0
- core/cluster/consensus/__init__.py +9 -0
- core/cluster/consensus/consensus.py +44 -0
- core/cluster/events.py +10 -0
- core/cluster/health.py +8 -0
- core/cluster/lifecycle.py +6 -0
- core/cluster/manager.py +24 -0
- core/cluster/membership.py +16 -0
- core/cluster/state.py +11 -0
- core/communication/__init__.py +100 -0
- core/communication/cache/__init__.py +8 -0
- core/communication/cache/cache.py +72 -0
- core/communication/compression/__init__.py +12 -0
- core/communication/compression/compression.py +51 -0
- core/communication/connection/__init__.py +106 -0
- core/communication/discovery/__init__.py +214 -0
- core/communication/discovery/discovery.py +0 -0
- core/communication/encryption/__init__.py +68 -0
- core/communication/encryption/encryption.py +0 -0
- core/communication/errors/__init__.py +65 -0
- core/communication/events/__init__.py +130 -0
- core/communication/gateway/__init__.py +9 -0
- core/communication/gateway/gateway.py +156 -0
- core/communication/heartbeat/__init__.py +116 -0
- core/communication/heartbeat/heartbeat.py +0 -0
- core/communication/identity/__init__.py +180 -0
- core/communication/identity/identity.py +0 -0
- core/communication/interfaces/__init__.py +57 -0
- core/communication/interfaces/interfaces.py +193 -0
- core/communication/latency/__init__.py +8 -0
- core/communication/latency/latency.py +77 -0
- core/communication/layer.py +857 -0
- core/communication/messaging/__init__.py +95 -0
- core/communication/messaging/messaging.py +0 -0
- core/communication/messaging/secure_bus.py +144 -0
- core/communication/monitoring/__init__.py +8 -0
- core/communication/monitoring/monitor.py +64 -0
- core/communication/network/__init__.py +77 -0
- core/communication/network/context.py +59 -0
- core/communication/network/events.py +47 -0
- core/communication/network/monitor.py +140 -0
- core/communication/network/resolver.py +125 -0
- core/communication/network/transport.py +197 -0
- core/communication/network/tuner.py +94 -0
- core/communication/peer/__init__.py +188 -0
- core/communication/peer/peer.py +0 -0
- core/communication/plugins/__init__.py +76 -0
- core/communication/protocols/__init__.py +0 -0
- core/communication/protocols/protocol.py +0 -0
- core/communication/qos/__init__.py +8 -0
- core/communication/qos/qos.py +99 -0
- core/communication/registry.py +83 -0
- core/communication/relay/__init__.py +84 -0
- core/communication/reliability/__init__.py +8 -0
- core/communication/reliability/reliability.py +97 -0
- core/communication/routing/__init__.py +54 -0
- core/communication/routing/router.py +0 -0
- core/communication/security/__init__.py +100 -0
- core/communication/security/handshake.py +120 -0
- core/communication/security/security.py +110 -0
- core/communication/serialization/__init__.py +128 -0
- core/communication/serialization/serialization.py +0 -0
- core/communication/sessions/__init__.py +109 -0
- core/communication/sessions/session.py +0 -0
- core/communication/streaming/__init__.py +21 -0
- core/communication/streaming/bandwidth_optimizer/__init__.py +8 -0
- core/communication/streaming/bandwidth_optimizer/bandwidth_optimizer.py +68 -0
- core/communication/streaming/checkpoint_sync/__init__.py +8 -0
- core/communication/streaming/checkpoint_sync/checkpoint_sync.py +28 -0
- core/communication/streaming/checksum/__init__.py +8 -0
- core/communication/streaming/checksum/checksum.py +48 -0
- core/communication/streaming/chunk_manager/__init__.py +8 -0
- core/communication/streaming/chunk_manager/chunk_manager.py +100 -0
- core/communication/streaming/dataset_sync/__init__.py +8 -0
- core/communication/streaming/dataset_sync/dataset_sync.py +28 -0
- core/communication/streaming/file_transfer/__init__.py +8 -0
- core/communication/streaming/file_transfer/file_transfer.py +28 -0
- core/communication/streaming/media_stream/__init__.py +8 -0
- core/communication/streaming/media_stream/media_stream.py +28 -0
- core/communication/streaming/model_distribution/__init__.py +8 -0
- core/communication/streaming/model_distribution/model_distribution.py +28 -0
- core/communication/streaming/replication/__init__.py +8 -0
- core/communication/streaming/replication/replication.py +28 -0
- core/communication/streaming/resume_manager/__init__.py +8 -0
- core/communication/streaming/resume_manager/resume_manager.py +84 -0
- core/communication/streaming/scheduler/__init__.py +76 -0
- core/communication/streaming/secure_transfer.py +90 -0
- core/communication/streaming/synchronization/__init__.py +8 -0
- core/communication/streaming/synchronization/synchronization.py +28 -0
- core/communication/streaming/tensor_stream/__init__.py +8 -0
- core/communication/streaming/tensor_stream/tensor_stream.py +28 -0
- core/communication/streaming/transfer_manager/__init__.py +8 -0
- core/communication/streaming/transfer_manager/transfer_manager.py +212 -0
- core/communication/topology/__init__.py +74 -0
- core/communication/transport/__init__.py +1 -0
- core/communication/transport/future/__init__.py +0 -0
- core/communication/transport/future/transport.py +0 -0
- core/communication/transport/grpc/__init__.py +0 -0
- core/communication/transport/grpc/transport.py +0 -0
- core/communication/transport/quic/__init__.py +0 -0
- core/communication/transport/quic/client.py +0 -0
- core/communication/transport/quic/connection.py +0 -0
- core/communication/transport/quic/server.py +0 -0
- core/communication/transport/quic/transport.py +0 -0
- core/communication/transport/tcp/__init__.py +149 -0
- core/communication/transport/tcp/client.py +0 -0
- core/communication/transport/tcp/connection.py +0 -0
- core/communication/transport/tcp/server.py +0 -0
- core/communication/transport/tcp/transport.py +0 -0
- core/communication/transport/websocket/__init__.py +0 -0
- core/communication/transport/websocket/transport.py +0 -0
- core/communication/traversal/__init__.py +60 -0
- core/configuration/__init__.py +0 -0
- core/configuration/configuration.py +0 -0
- core/configuration/scopes.py +13 -0
- core/diagnostics/__init__.py +0 -0
- core/diagnostics/diagnostics.py +0 -0
- core/discovery/__init__.py +0 -0
- core/discovery/context.py +9 -0
- core/discovery/events.py +10 -0
- core/discovery/failure/__init__.py +0 -0
- core/discovery/failure/detector.py +6 -0
- core/discovery/failure/isolation.py +5 -0
- core/discovery/failure/suspicion.py +5 -0
- core/discovery/gossip/__init__.py +0 -0
- core/discovery/gossip/exchange.py +5 -0
- core/discovery/gossip/manager.py +6 -0
- core/discovery/gossip/protocol.py +9 -0
- core/discovery/gossip/state.py +9 -0
- core/discovery/heartbeat/__init__.py +0 -0
- core/discovery/heartbeat/manager.py +5 -0
- core/discovery/heartbeat/monitor.py +5 -0
- core/discovery/heartbeat/scheduler.py +6 -0
- core/discovery/manager.py +8 -0
- core/discovery/policies.py +9 -0
- core/discovery/registry.py +11 -0
- core/discovery/runtime.py +7 -0
- core/discovery/state.py +9 -0
- core/federation/__init__.py +0 -0
- core/federation/directory.py +5 -0
- core/federation/discovery.py +5 -0
- core/federation/manager.py +5 -0
- core/federation/policies.py +5 -0
- core/federation/registry.py +5 -0
- core/federation/remote.py +5 -0
- core/federation/routing.py +5 -0
- core/federation/trust.py +5 -0
- core/interfaces/__init__.py +325 -0
- core/interfaces/icluster.py +1 -0
- core/interfaces/icommunication.py +0 -0
- core/interfaces/idataset.py +0 -0
- core/interfaces/imodel.py +0 -0
- core/interfaces/iplugin.py +0 -0
- core/interfaces/iresource.py +0 -0
- core/interfaces/iruntime.py +0 -0
- core/interfaces/ischeduler.py +0 -0
- core/interfaces/isecurity.py +0 -0
- core/interfaces/istorage.py +0 -0
- core/interfaces/istreaming.py +0 -0
- core/interfaces/itelemetry.py +0 -0
- core/interfaces/itransport.py +0 -0
- core/kernel/__init__.py +0 -0
- core/kernel/context.py +19 -0
- core/kernel/diagnostics.py +15 -0
- core/kernel/events.py +13 -0
- core/kernel/health.py +19 -0
- core/kernel/kernel.py +23 -0
- core/kernel/lifecycle.py +35 -0
- core/kernel/manifest.py +29 -0
- core/kernel/runtimes/__init__.py +0 -0
- core/kernel/runtimes/descriptor.py +30 -0
- core/kernel/runtimes/registry.py +21 -0
- core/kernel/state.py +39 -0
- core/logging/__init__.py +0 -0
- core/logging/logging.py +0 -0
- core/logging_setup.py +98 -0
- core/network/__init__.py +0 -0
- core/network/bus.py +56 -0
- core/network/config.py +202 -0
- core/network/connection/__init__.py +0 -0
- core/network/connection/manager.py +57 -0
- core/network/connection/pool.py +43 -0
- core/network/connection/registry.py +19 -0
- core/network/connection/retry.py +30 -0
- core/network/connection/state.py +64 -0
- core/network/controlplane/__init__.py +0 -0
- core/network/controlplane/acl/__init__.py +0 -0
- core/network/controlplane/acl/acl_manager.py +69 -0
- core/network/controlplane/audit/__init__.py +0 -0
- core/network/controlplane/audit/logger.py +33 -0
- core/network/controlplane/authentication/__init__.py +0 -0
- core/network/controlplane/authentication/auth.py +64 -0
- core/network/controlplane/authorization/__init__.py +0 -0
- core/network/controlplane/authorization/authz.py +42 -0
- core/network/controlplane/cluster/__init__.py +0 -0
- core/network/controlplane/cluster/synchronizer.py +32 -0
- core/network/controlplane/configuration/__init__.py +0 -0
- core/network/controlplane/configuration/manager.py +37 -0
- core/network/controlplane/derp/__init__.py +0 -0
- core/network/controlplane/derp/derp_coordinator.py +31 -0
- core/network/controlplane/events.py +57 -0
- core/network/controlplane/exceptions.py +26 -0
- core/network/controlplane/identity/__init__.py +0 -0
- core/network/controlplane/identity/manager.py +92 -0
- core/network/controlplane/models.py +70 -0
- core/network/controlplane/monitoring/__init__.py +0 -0
- core/network/controlplane/monitoring/monitor.py +27 -0
- core/network/controlplane/nat/__init__.py +0 -0
- core/network/controlplane/nat/nat_coordinator.py +30 -0
- core/network/controlplane/peer_coordinator.py +40 -0
- core/network/controlplane/registry/__init__.py +0 -0
- core/network/controlplane/registry/registry.py +67 -0
- core/network/controlplane/routing/__init__.py +0 -0
- core/network/controlplane/routing/routing.py +32 -0
- core/network/controlplane/services/__init__.py +0 -0
- core/network/controlplane/services/identity_service.py +16 -0
- core/network/controlplane/topology/__init__.py +0 -0
- core/network/controlplane/topology/topology.py +54 -0
- core/network/discovery/__init__.py +0 -0
- core/network/discovery/cache.py +30 -0
- core/network/discovery/interfaces.py +43 -0
- core/network/discovery/manager.py +49 -0
- core/network/discovery/provider.py +331 -0
- core/network/discovery/synchronizer.py +75 -0
- core/network/events.py +136 -0
- core/network/exceptions.py +34 -0
- core/network/headscale/__init__.py +0 -0
- core/network/headscale/acl.py +11 -0
- core/network/headscale/api.py +132 -0
- core/network/headscale/client.py +163 -0
- core/network/headscale/headscale_state.py +107 -0
- core/network/headscale/headscale_sync_service.py +349 -0
- core/network/headscale/health.py +76 -0
- core/network/headscale/identity.py +8 -0
- core/network/headscale/models.py +28 -0
- core/network/headscale/registration.py +368 -0
- core/network/headscale/startup_check.py +651 -0
- core/network/headscale/sync.py +75 -0
- core/network/health/__init__.py +0 -0
- core/network/health/monitor.py +50 -0
- core/network/health/states.py +13 -0
- core/network/management/__init__.py +0 -0
- core/network/management/config.py +35 -0
- core/network/management/doctor.py +70 -0
- core/network/management/headscale.py +77 -0
- core/network/management/installer.py +44 -0
- core/network/management/logs.py +21 -0
- core/network/management/models.py +58 -0
- core/network/management/operator.py +37 -0
- core/network/management/provision.py +20 -0
- core/network/management/tailscale.py +125 -0
- core/network/manager.py +266 -0
- core/network/metrics/__init__.py +6 -0
- core/network/metrics/manager.py +77 -0
- core/network/orchestrator/__init__.py +0 -0
- core/network/orchestrator/orchestrator.py +125 -0
- core/network/orchestrator/route_evaluator.py +56 -0
- core/network/platform/__init__.py +17 -0
- core/network/platform/capabilities.py +237 -0
- core/network/scheduler/__init__.py +0 -0
- core/network/scheduler/network_scheduler.py +0 -0
- core/network/security/__init__.py +0 -0
- core/network/security/policy.py +0 -0
- core/network/services/__init__.py +0 -0
- core/network/services/heartbeat.py +149 -0
- core/network/session/__init__.py +0 -0
- core/network/session/manager.py +139 -0
- core/network/transfer/__init__.py +0 -0
- core/network/transfer/checksum.py +13 -0
- core/network/transfer/chunk_manager.py +17 -0
- core/network/transfer/compression.py +13 -0
- core/network/transfer/reassembly.py +27 -0
- core/network/transfer/resume.py +36 -0
- core/network/transfer/transfer_manager.py +103 -0
- core/network/transfer/verification.py +13 -0
- core/network/transport/__init__.py +0 -0
- core/network/transport/base.py +125 -0
- core/network/transport/factory.py +27 -0
- core/network/transport/interfaces.py +90 -0
- core/network/transport/manager.py +37 -0
- core/network/transport/mock_provider.py +60 -0
- core/network/transport/provider.py +62 -0
- core/network/transport/tcp_provider.py +45 -0
- core/network/wireguard/__init__.py +0 -0
- core/network/wireguard/health_monitor.py +30 -0
- core/network/wireguard/interface_manager.py +19 -0
- core/network/wireguard/key_manager.py +61 -0
- core/network/wireguard/peer_manager.py +33 -0
- core/network/wireguard/provider.py +41 -0
- core/network/wireguard/system_provider.py +85 -0
- core/network/wireguard/tunnel_manager.py +25 -0
- core/node/__init__.py +0 -0
- core/node/descriptor.py +10 -0
- core/node/events.py +9 -0
- core/node/health.py +6 -0
- core/node/identity.py +9 -0
- core/node/lifecycle.py +27 -0
- core/node/manager.py +10 -0
- core/node/state.py +15 -0
- core/platform/__init__.py +0 -0
- core/platform/common/__init__.py +0 -0
- core/platform/common/common.py +0 -0
- core/platform/drivers/__init__.py +0 -0
- core/platform/drivers/drivers.py +0 -0
- core/platform/linux/__init__.py +0 -0
- core/platform/linux/linux.py +0 -0
- core/platform/macos/__init__.py +0 -0
- core/platform/macos/macos.py +0 -0
- core/platform/windows/__init__.py +0 -0
- core/platform/windows/windows.py +0 -0
- core/plugins/__init__.py +0 -0
- core/plugins/manager.py +17 -0
- core/plugins/manifest.py +24 -0
- core/plugins/registry.py +11 -0
- core/research/__init__.py +9 -0
- core/resource_fabric/__init__.py +0 -0
- core/resource_fabric/admission_control/__init__.py +0 -0
- core/resource_fabric/admission_control/admission_control.py +0 -0
- core/resource_fabric/allocator/__init__.py +0 -0
- core/resource_fabric/allocator/allocator.py +0 -0
- core/resource_fabric/discovery/__init__.py +0 -0
- core/resource_fabric/discovery/discovery.py +0 -0
- core/resource_fabric/gpu_pool/__init__.py +0 -0
- core/resource_fabric/gpu_pool/gpu_pool.py +0 -0
- core/resource_fabric/inventory/__init__.py +0 -0
- core/resource_fabric/inventory/inventory.py +0 -0
- core/resource_fabric/memory_pool/__init__.py +0 -0
- core/resource_fabric/memory_pool/memory_pool.py +0 -0
- core/resource_fabric/network_pool/__init__.py +0 -0
- core/resource_fabric/network_pool/network_pool.py +0 -0
- core/resource_fabric/placement/__init__.py +0 -0
- core/resource_fabric/placement/placement.py +0 -0
- core/resource_fabric/quotas/__init__.py +0 -0
- core/resource_fabric/quotas/quotas.py +0 -0
- core/resource_fabric/storage_pool/__init__.py +0 -0
- core/resource_fabric/storage_pool/storage_pool.py +0 -0
- core/resources/__init__.py +0 -0
- core/resources/allocator/__init__.py +0 -0
- core/resources/allocator/allocator.py +0 -0
- core/resources/bandwidth/__init__.py +0 -0
- core/resources/bandwidth/bandwidth.py +0 -0
- core/resources/cpu/__init__.py +0 -0
- core/resources/cpu/cpu.py +0 -0
- core/resources/disk/__init__.py +0 -0
- core/resources/disk/disk.py +0 -0
- core/resources/gpu/__init__.py +0 -0
- core/resources/gpu/gpu.py +0 -0
- core/resources/manager.py +12 -0
- core/resources/memory/__init__.py +0 -0
- core/resources/memory/memory.py +0 -0
- core/resources/models.py +42 -0
- core/resources/network/__init__.py +0 -0
- core/resources/network/network.py +0 -0
- core/resources/npu/__init__.py +0 -0
- core/resources/npu/npu.py +0 -0
- core/resources/power/__init__.py +0 -0
- core/resources/power/power.py +0 -0
- core/resources/predictor/__init__.py +0 -0
- core/resources/predictor/predictor.py +0 -0
- core/resources/registry.py +11 -0
- core/resources/storage/__init__.py +0 -0
- core/resources/storage/storage.py +0 -0
- core/resources/telemetry/__init__.py +0 -0
- core/resources/telemetry/telemetry.py +0 -0
- core/resources/temperature/__init__.py +0 -0
- core/resources/temperature/temperature.py +0 -0
- core/runtime/__init__.py +0 -0
- core/runtime/event_bus/__init__.py +0 -0
- core/runtime/event_bus/event_bus.py +0 -0
- core/runtime/executor/__init__.py +0 -0
- core/runtime/executor/executor.py +0 -0
- core/runtime/job_dispatcher/__init__.py +0 -0
- core/runtime/job_dispatcher/job_dispatcher.py +0 -0
- core/runtime/lifecycle/__init__.py +0 -0
- core/runtime/lifecycle/lifecycle.py +0 -0
- core/runtime/plugin_manager/__init__.py +0 -0
- core/runtime/plugin_manager/plugin_manager.py +0 -0
- core/runtime/runtime_api/__init__.py +0 -0
- core/runtime/runtime_api/runtime_api.py +0 -0
- core/runtime/scheduler/__init__.py +0 -0
- core/runtime/scheduler/scheduler.py +0 -0
- core/runtime/service_manager/__init__.py +0 -0
- core/runtime/service_manager/service_manager.py +0 -0
- core/runtime/state_machine/__init__.py +0 -0
- core/runtime/state_machine/state_machine.py +0 -0
- core/runtime/task_manager/__init__.py +0 -0
- core/runtime/task_manager/task_manager.py +0 -0
- core/runtime/task_queue/__init__.py +0 -0
- core/runtime/task_queue/task_queue.py +0 -0
- core/runtime/worker_pool/__init__.py +0 -0
- core/runtime/worker_pool/worker_pool.py +0 -0
- core/scheduler/__init__.py +0 -0
- core/scheduler/execution_flow.py +8 -0
- core/scheduler/executor.py +8 -0
- core/scheduler/placement.py +7 -0
- core/scheduler/queue.py +7 -0
- core/scheduler/scheduler.py +8 -0
- core/security/__init__.py +1 -0
- core/security/audit/__init__.py +0 -0
- core/security/audit/journal.py +12 -0
- core/security/audit/logger.py +7 -0
- core/security/audit/retention.py +10 -0
- core/security/authentication/__init__.py +0 -0
- core/security/authentication/handshake.py +16 -0
- core/security/authentication/manager.py +17 -0
- core/security/authentication/policy.py +12 -0
- core/security/authorization/__init__.py +1 -0
- core/security/authorization/manager.py +21 -0
- core/security/authorization/policy.py +10 -0
- core/security/authorization/rbac.py +23 -0
- core/security/bus_integration.py +8 -0
- core/security/crypto/__init__.py +0 -0
- core/security/crypto/keys.py +18 -0
- core/security/crypto/provider.py +38 -0
- core/security/domains/__init__.py +0 -0
- core/security/domains/domain.py +29 -0
- core/security/hardware/__init__.py +0 -0
- core/security/hardware/provider.py +21 -0
- core/security/identity/__init__.py +0 -0
- core/security/identity/descriptor.py +13 -0
- core/security/identity/identity.py +36 -0
- core/security/identity/registry.py +17 -0
- core/security/identity/validator.py +13 -0
- core/security/identity_store.py +34 -0
- core/security/peer_registry.py +56 -0
- core/security/pki/__init__.py +3 -0
- core/security/pki/authority.py +12 -0
- core/security/pki/ca.py +118 -0
- core/security/pki/csr.py +10 -0
- core/security/pki/manager.py +14 -0
- core/security/pki/revocation.py +13 -0
- core/security/pki/store.py +20 -0
- core/security/pki/validator.py +16 -0
- core/security/policy/__init__.py +1 -0
- core/security/policy/policy.py +103 -0
- core/security/runtime/__init__.py +0 -0
- core/security/runtime/context.py +22 -0
- core/security/runtime/events.py +37 -0
- core/security/runtime/lifecycle.py +26 -0
- core/security/runtime/manager.py +49 -0
- core/security/secrets/__init__.py +1 -0
- core/security/secrets/manager.py +7 -0
- core/security/secrets/provider.py +9 -0
- core/security/secrets/rotation.py +6 -0
- core/security/secrets/store.py +14 -0
- core/security/secrets/vault.py +65 -0
- core/security/security.py +0 -0
- core/security/sessions/__init__.py +0 -0
- core/security/sessions/descriptor.py +11 -0
- core/security/sessions/lifecycle.py +12 -0
- core/security/sessions/manager.py +18 -0
- core/security/sessions/state.py +11 -0
- core/security/threats/__init__.py +0 -0
- core/security/threats/catalog.py +23 -0
- core/security/threats/classification.py +17 -0
- core/security/threats/mitigation.py +11 -0
- core/security/threats/severity.py +23 -0
- core/security/trust/__init__.py +1 -0
- core/security/trust/engine.py +16 -0
- core/security/trust/evaluator.py +6 -0
- core/security/trust/evidence.py +17 -0
- core/security/trust/graph.py +11 -0
- core/security/trust/manager.py +16 -0
- core/security/trust/policy.py +9 -0
- core/security/trust/reputation.py +3 -0
- core/security/trust/trust.py +62 -0
- core/services/__init__.py +0 -0
- core/services/authentication/__init__.py +0 -0
- core/services/authentication/service.py +0 -0
- core/services/cache/__init__.py +0 -0
- core/services/cache/service.py +0 -0
- core/services/descriptor.py +7 -0
- core/services/discovery/__init__.py +0 -0
- core/services/discovery/service.py +0 -0
- core/services/discovery.py +7 -0
- core/services/health/__init__.py +0 -0
- core/services/health/service.py +0 -0
- core/services/health.py +7 -0
- core/services/heartbeat/__init__.py +0 -0
- core/services/heartbeat/service.py +0 -0
- core/services/lifecycle.py +7 -0
- core/services/logging/__init__.py +0 -0
- core/services/logging/service.py +0 -0
- core/services/manager.py +7 -0
- core/services/manifest.py +7 -0
- core/services/metrics/__init__.py +0 -0
- core/services/metrics/service.py +0 -0
- core/services/notifications/__init__.py +0 -0
- core/services/notifications/service.py +0 -0
- core/services/registry.py +7 -0
- core/services/resolver.py +7 -0
- core/services/resource_monitor/__init__.py +0 -0
- core/services/resource_monitor/service.py +0 -0
- core/services/runtime.py +8 -0
- core/services/scheduler/__init__.py +0 -0
- core/services/scheduler/service.py +0 -0
- core/services/state.py +24 -0
- core/services/sync/__init__.py +0 -0
- core/services/sync/service.py +0 -0
- core/services/transfer/__init__.py +0 -0
- core/services/transfer/service.py +0 -0
- core/storage/__init__.py +0 -0
- core/storage/artifacts/__init__.py +0 -0
- core/storage/artifacts/artifacts.py +0 -0
- core/storage/cache/__init__.py +0 -0
- core/storage/cache/cache.py +0 -0
- core/storage/checkpoints/__init__.py +0 -0
- core/storage/checkpoints/checkpoints.py +0 -0
- core/storage/cleanup/__init__.py +0 -0
- core/storage/cleanup/cleanup.py +0 -0
- core/storage/datasets/__init__.py +0 -0
- core/storage/datasets/datasets.py +0 -0
- core/storage/distributed_store/__init__.py +0 -0
- core/storage/distributed_store/distributed_store.py +0 -0
- core/storage/logs/__init__.py +0 -0
- core/storage/logs/logs.py +0 -0
- core/storage/metadata/__init__.py +0 -0
- core/storage/metadata/metadata.py +0 -0
- core/storage/metadata/store.py +7 -0
- core/storage/models/__init__.py +0 -0
- core/storage/models/models.py +0 -0
- core/storage/object_store/__init__.py +0 -0
- core/storage/object_store/object_store.py +0 -0
- core/storage/replication/__init__.py +0 -0
- core/storage/replication/replication.py +0 -0
- core/storage/snapshots/__init__.py +0 -0
- core/storage/snapshots/snapshots.py +0 -0
- core/system/__init__.py +0 -0
- core/system/bus.py +15 -0
- core/system/commands.py +7 -0
- core/system/events.py +7 -0
- core/system/queries.py +7 -0
- core/system/subscriptions.py +7 -0
- core/telemetry/__init__.py +0 -0
- core/telemetry/alerts/__init__.py +0 -0
- core/telemetry/alerts/alerts.py +0 -0
- core/telemetry/analytics/__init__.py +0 -0
- core/telemetry/analytics/analytics.py +0 -0
- core/telemetry/dashboards/__init__.py +0 -0
- core/telemetry/dashboards/dashboards.py +0 -0
- core/telemetry/events/__init__.py +0 -0
- core/telemetry/events/events.py +0 -0
- core/telemetry/metrics/__init__.py +0 -0
- core/telemetry/metrics/metrics.py +0 -0
- core/telemetry/profiling/__init__.py +0 -0
- core/telemetry/profiling/profiling.py +0 -0
- core/telemetry/tracing/__init__.py +0 -0
- core/telemetry/tracing/tracing.py +0 -0
- core/time/__init__.py +0 -0
- core/time/clock.py +5 -0
- core/time/logical.py +5 -0
- core/time/synchronization.py +5 -0
- core/time/vector.py +5 -0
- core/topology/__init__.py +0 -0
- core/topology/graph.py +5 -0
- core/topology/manager.py +5 -0
- core/topology/snapshot.py +5 -0
- core/utilities/__init__.py +0 -0
- core/utilities/utilities.py +0 -0
- protocol/__init__.py +0 -0
- protocol/commands/__init__.py +0 -0
- protocol/commands/commands.py +0 -0
- protocol/errors/__init__.py +0 -0
- protocol/errors/errors.py +0 -0
- protocol/events/__init__.py +0 -0
- protocol/events/events.py +0 -0
- protocol/messages/__init__.py +0 -0
- protocol/messages/messages.py +0 -0
- protocol/protobuf/__init__.py +0 -0
- protocol/responses/__init__.py +0 -0
- protocol/responses/responses.py +0 -0
- protocol/schemas/__init__.py +416 -0
- protocol/versioning/__init__.py +0 -0
- protocol/versioning/versioning.py +0 -0
- protocol/wire/__init__.py +0 -0
- protocol/wire/common/__init__.py +0 -0
- protocol/wire/common/types.py +7 -0
- protocol/wire/evolution.py +10 -0
- vayrm/__init__.py +8 -0
- vayrm-0.1.0.dist-info/METADATA +166 -0
- vayrm-0.1.0.dist-info/RECORD +986 -0
- vayrm-0.1.0.dist-info/WHEEL +5 -0
- vayrm-0.1.0.dist-info/entry_points.txt +3 -0
- vayrm-0.1.0.dist-info/top_level.txt +7 -0
acr/__init__.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Adaptive Computing Resource (ACR)
|
|
3
|
+
=================================
|
|
4
|
+
|
|
5
|
+
ACR is a platform-agnostic, distributed computing runtime for heterogeneous clusters.
|
|
6
|
+
It provides node intelligence, cluster knowledge exchange, adaptive scheduling,
|
|
7
|
+
and closed-loop execution feedback.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from acr.facade import ACRNode, ACRRoot
|
|
11
|
+
from acr.workloads import Workload
|
|
12
|
+
from acr.schedulers.adaptive import AdaptiveScheduler
|
|
13
|
+
from acr.schedulers.decision import SchedulingDecision
|
|
14
|
+
from acr.execution.manager import ExecutionManager
|
|
15
|
+
from acr.execution.models import ExecutionAttempt
|
|
16
|
+
from acr.communication.protocol import ExecutionObservationMessage as ExecutionObservation
|
|
17
|
+
from acr.resources.snapshot import NodeSnapshot
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"ACRNode",
|
|
21
|
+
"ACRRoot",
|
|
22
|
+
"Workload",
|
|
23
|
+
"AdaptiveScheduler",
|
|
24
|
+
"SchedulingDecision",
|
|
25
|
+
"ExecutionManager",
|
|
26
|
+
"ExecutionAttempt",
|
|
27
|
+
"ExecutionObservation",
|
|
28
|
+
"NodeSnapshot",
|
|
29
|
+
]
|
acr/api/__init__.py
ADDED
|
File without changes
|
acr/api/root_api.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Dict, List, Optional
|
|
3
|
+
from acr.node.knowledge import NodeKnowledge
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class WorkerRecord:
|
|
7
|
+
worker_key: str
|
|
8
|
+
endpoint: Optional[Dict]
|
|
9
|
+
paladin_node_id: str
|
|
10
|
+
session_id: Optional[str]
|
|
11
|
+
connection: str
|
|
12
|
+
connection_status: str
|
|
13
|
+
telemetry: Optional[dict]
|
|
14
|
+
knowledge: Optional[NodeKnowledge]
|
|
15
|
+
|
|
16
|
+
class RootDashboardAPI:
|
|
17
|
+
"""
|
|
18
|
+
API for retrieving WorkerRecords for the dashboard.
|
|
19
|
+
"""
|
|
20
|
+
def __init__(self, root_brain, control_plane):
|
|
21
|
+
self._brain = root_brain
|
|
22
|
+
self._cp = control_plane
|
|
23
|
+
|
|
24
|
+
def get_workers(self) -> List[WorkerRecord]:
|
|
25
|
+
workers = []
|
|
26
|
+
all_k = self._brain.all_node_knowledge()
|
|
27
|
+
tracker = getattr(self._cp, "telemetry_tracker", None)
|
|
28
|
+
|
|
29
|
+
# We also want to include nodes that the tracker knows about but have no knowledge yet
|
|
30
|
+
worker_keys = set(all_k.keys())
|
|
31
|
+
if tracker:
|
|
32
|
+
worker_keys.update(rec.node_id for rec in tracker.all_records())
|
|
33
|
+
|
|
34
|
+
for worker_key in worker_keys:
|
|
35
|
+
# worker_key is usually "{paladin_node_id}_{session_id}"
|
|
36
|
+
if "_" in worker_key:
|
|
37
|
+
paladin_node_id, session_id = worker_key.split("_", 1)
|
|
38
|
+
else:
|
|
39
|
+
paladin_node_id, session_id = worker_key, None
|
|
40
|
+
|
|
41
|
+
k = all_k.get(worker_key)
|
|
42
|
+
ep = None
|
|
43
|
+
conn_status = "UNKNOWN"
|
|
44
|
+
tel = None
|
|
45
|
+
|
|
46
|
+
if tracker:
|
|
47
|
+
rec = tracker.get_record(worker_key)
|
|
48
|
+
if rec:
|
|
49
|
+
tel = rec.__dict__
|
|
50
|
+
if rec.current_mesh_ip:
|
|
51
|
+
ep = {
|
|
52
|
+
"mesh_ip": rec.current_mesh_ip,
|
|
53
|
+
"service_port": rec.current_service_port
|
|
54
|
+
}
|
|
55
|
+
conn_status = rec.connection_status
|
|
56
|
+
|
|
57
|
+
if not ep and hasattr(self._cp, "get_node_endpoint"):
|
|
58
|
+
# fallback to paladin directly if tracker missed it
|
|
59
|
+
ep_data = self._cp.get_node_endpoint(paladin_node_id)
|
|
60
|
+
if ep_data:
|
|
61
|
+
ep = {
|
|
62
|
+
"mesh_ip": ep_data.get("mesh_ip"),
|
|
63
|
+
"service_port": ep_data.get("service_port")
|
|
64
|
+
}
|
|
65
|
+
if conn_status == "UNKNOWN":
|
|
66
|
+
conn_status = ep_data.get("connection_status", "UNKNOWN")
|
|
67
|
+
|
|
68
|
+
workers.append(WorkerRecord(
|
|
69
|
+
worker_key=worker_key,
|
|
70
|
+
endpoint=ep,
|
|
71
|
+
paladin_node_id=paladin_node_id,
|
|
72
|
+
session_id=session_id,
|
|
73
|
+
connection="PALADIN",
|
|
74
|
+
connection_status=conn_status,
|
|
75
|
+
telemetry=tel,
|
|
76
|
+
knowledge=k
|
|
77
|
+
))
|
|
78
|
+
|
|
79
|
+
# Sort so order is stable
|
|
80
|
+
workers.sort(key=lambda w: w.worker_key)
|
|
81
|
+
return workers
|
|
82
|
+
|
|
83
|
+
def get_worker(self, worker_key: str) -> Optional[WorkerRecord]:
|
|
84
|
+
for w in self.get_workers():
|
|
85
|
+
if w.worker_key == worker_key:
|
|
86
|
+
return w
|
|
87
|
+
return None
|
acr/api/server.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""
|
|
2
|
+
acr/api/server.py
|
|
3
|
+
FastAPI server exposing real-time state of the NodeBrain and WorkloadBrain.
|
|
4
|
+
"""
|
|
5
|
+
from fastapi import FastAPI, HTTPException
|
|
6
|
+
import uuid
|
|
7
|
+
import threading
|
|
8
|
+
|
|
9
|
+
from acr.runtime.node_brain import NodeBrain
|
|
10
|
+
from acr.runtime.workload_brain import WorkloadBrain
|
|
11
|
+
from acr.runtime.monitoring import RuntimeMonitor
|
|
12
|
+
from acr.workloads.pytorch.adapter import PyTorchWorkloadAdapter
|
|
13
|
+
from acr.workloads.pytorch.checkpoint import PyTorchCheckpointer
|
|
14
|
+
from acr.workloads.pytorch.runtime import run_training
|
|
15
|
+
|
|
16
|
+
app = FastAPI(title="ACR Live Runtime API", version="1.0.0")
|
|
17
|
+
|
|
18
|
+
# Global instances for the runtime
|
|
19
|
+
run_id = str(uuid.uuid4())
|
|
20
|
+
node_brain = NodeBrain(node_id="macos_node_1")
|
|
21
|
+
workload_brain = WorkloadBrain(workload_id="pytorch_resnet_1")
|
|
22
|
+
monitor = RuntimeMonitor(node_brain, workload_brain, run_id=run_id, interval_s=1.0)
|
|
23
|
+
adapter = PyTorchWorkloadAdapter(workload_brain)
|
|
24
|
+
checkpointer = PyTorchCheckpointer(f"checkpoints/{run_id}")
|
|
25
|
+
|
|
26
|
+
training_thread = None
|
|
27
|
+
|
|
28
|
+
@app.on_event("startup")
|
|
29
|
+
def startup_event():
|
|
30
|
+
print("Starting Continuous Node Monitor...")
|
|
31
|
+
monitor.start()
|
|
32
|
+
|
|
33
|
+
@app.on_event("shutdown")
|
|
34
|
+
def shutdown_event():
|
|
35
|
+
print("Stopping runtime...")
|
|
36
|
+
monitor.stop()
|
|
37
|
+
adapter.stop()
|
|
38
|
+
if training_thread:
|
|
39
|
+
training_thread.join(timeout=2.0)
|
|
40
|
+
|
|
41
|
+
@app.get("/api/v1/node")
|
|
42
|
+
def get_node_state():
|
|
43
|
+
"""Returns the current state and trends of the physical node."""
|
|
44
|
+
return node_brain.get_state_summary()
|
|
45
|
+
|
|
46
|
+
@app.get("/api/v1/workload")
|
|
47
|
+
def get_workload_state():
|
|
48
|
+
"""Returns the current state and metrics of the running workload."""
|
|
49
|
+
return workload_brain.get_state_summary()
|
|
50
|
+
|
|
51
|
+
@app.post("/api/v1/workload/start")
|
|
52
|
+
def start_workload(device: str = "cpu", batch_size: int = 64):
|
|
53
|
+
"""Start the real PyTorch workload in a background thread."""
|
|
54
|
+
global training_thread
|
|
55
|
+
if training_thread and training_thread.is_alive():
|
|
56
|
+
raise HTTPException(status_code=400, detail="Workload is already running")
|
|
57
|
+
|
|
58
|
+
training_thread = threading.Thread(
|
|
59
|
+
target=run_training,
|
|
60
|
+
args=(adapter, checkpointer, device, batch_size),
|
|
61
|
+
daemon=True
|
|
62
|
+
)
|
|
63
|
+
training_thread.start()
|
|
64
|
+
return {"status": "started", "device": device, "batch_size": batch_size}
|
|
65
|
+
|
|
66
|
+
@app.post("/api/v1/workload/stop")
|
|
67
|
+
def stop_workload():
|
|
68
|
+
"""Stop the running PyTorch workload."""
|
|
69
|
+
adapter.running = False
|
|
70
|
+
return {"status": "stopping"}
|
acr/cache/__init__.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""
|
|
2
|
+
acr/cache/__init__.py
|
|
3
|
+
|
|
4
|
+
Local state cache management for ACR nodes.
|
|
5
|
+
"""
|
|
6
|
+
from acr.cache.policy import (
|
|
7
|
+
CacheEntry, EvictionPolicy, AdmissionPolicy,
|
|
8
|
+
LRUEvictionPolicy, LFUEvictionPolicy, SizeAwareEvictionPolicy,
|
|
9
|
+
AlwaysAdmitPolicy, SizeThresholdPolicy,
|
|
10
|
+
)
|
|
11
|
+
from acr.cache.manager import (
|
|
12
|
+
CacheTier, CacheEventType, CacheEvent, CacheStats, CacheManager,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"CacheEntry", "EvictionPolicy", "AdmissionPolicy",
|
|
17
|
+
"LRUEvictionPolicy", "LFUEvictionPolicy", "SizeAwareEvictionPolicy",
|
|
18
|
+
"AlwaysAdmitPolicy", "SizeThresholdPolicy",
|
|
19
|
+
"CacheTier", "CacheEventType", "CacheEvent", "CacheStats", "CacheManager",
|
|
20
|
+
]
|
acr/cache/manager.py
ADDED
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
"""
|
|
2
|
+
acr/cache/manager.py
|
|
3
|
+
|
|
4
|
+
CacheManager: local state cache for an ACR node.
|
|
5
|
+
|
|
6
|
+
The CacheManager sits between the storage backend and the scheduler.
|
|
7
|
+
It answers: "Is this chunk available locally? Can I serve it without a
|
|
8
|
+
remote transfer?"
|
|
9
|
+
|
|
10
|
+
Responsibilities
|
|
11
|
+
----------------
|
|
12
|
+
- Admission: decide whether to accept a new chunk into the cache
|
|
13
|
+
- Eviction: free space when pressure requires it
|
|
14
|
+
- Promotion: move a chunk to a higher-priority tier
|
|
15
|
+
- Demotion: move a chunk to a lower-priority tier
|
|
16
|
+
- Prefetch: proactively fetch chunks expected to be needed soon
|
|
17
|
+
- Residency tracking: what chunks are cached and at what tier
|
|
18
|
+
- Hit/miss accounting: maintain statistics for scheduling decisions
|
|
19
|
+
|
|
20
|
+
Memory hierarchy (conceptual, represented as priority tiers)
|
|
21
|
+
-------------------------------------------------------------
|
|
22
|
+
Tier 0: GPU / accelerator memory (highest cost to reload)
|
|
23
|
+
Tier 1: RAM (system memory)
|
|
24
|
+
Tier 2: Local persistent storage
|
|
25
|
+
Tier 3: Remote (not cached — fetch required)
|
|
26
|
+
|
|
27
|
+
The CacheManager tracks tiers 0–2. Tier 3 means "not here".
|
|
28
|
+
The storage backend holds the actual bytes for tiers 1–2.
|
|
29
|
+
GPU residency is metadata-only (ACR does not manage GPU memory directly).
|
|
30
|
+
|
|
31
|
+
Design rules
|
|
32
|
+
------------
|
|
33
|
+
- CacheManager depends on StorageBackend (injected).
|
|
34
|
+
- CacheManager depends on EvictionPolicy and AdmissionPolicy (injected).
|
|
35
|
+
- All operations produce structured CacheEvent records.
|
|
36
|
+
- Cache hits/misses are counted per chunk_id.
|
|
37
|
+
- capacity_bytes is a soft limit: eviction is triggered when exceeded.
|
|
38
|
+
- Eviction frees at least one slot; it may free more if under severe pressure.
|
|
39
|
+
"""
|
|
40
|
+
from __future__ import annotations
|
|
41
|
+
|
|
42
|
+
import time
|
|
43
|
+
from dataclasses import dataclass, field
|
|
44
|
+
from enum import Enum
|
|
45
|
+
|
|
46
|
+
from acr.cache.policy import (
|
|
47
|
+
AdmissionPolicy, AlwaysAdmitPolicy, CacheEntry,
|
|
48
|
+
EvictionPolicy, LRUEvictionPolicy,
|
|
49
|
+
)
|
|
50
|
+
from acr.storage.backend import StorageBackend
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class CacheTier(Enum):
|
|
54
|
+
"""
|
|
55
|
+
Conceptual memory tier.
|
|
56
|
+
|
|
57
|
+
GPU : GPU / accelerator memory (fastest; metadata-only in ACR)
|
|
58
|
+
RAM : System RAM (fast; managed via storage backend)
|
|
59
|
+
STORAGE : Local persistent storage (slower; managed via storage backend)
|
|
60
|
+
REMOTE : Not locally cached
|
|
61
|
+
"""
|
|
62
|
+
GPU = 0
|
|
63
|
+
RAM = 1
|
|
64
|
+
STORAGE = 2
|
|
65
|
+
REMOTE = 3
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@dataclass
|
|
69
|
+
class CacheEventType(Enum):
|
|
70
|
+
HIT = "hit"
|
|
71
|
+
MISS = "miss"
|
|
72
|
+
ADMITTED = "admitted"
|
|
73
|
+
EVICTED = "evicted"
|
|
74
|
+
PROMOTED = "promoted"
|
|
75
|
+
DEMOTED = "demoted"
|
|
76
|
+
REJECTED = "rejected" # admission policy said no
|
|
77
|
+
PREFETCH = "prefetch"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@dataclass
|
|
81
|
+
class CacheEvent:
|
|
82
|
+
"""A structured event emitted by the CacheManager for observability."""
|
|
83
|
+
event_type: CacheEventType
|
|
84
|
+
chunk_id: str
|
|
85
|
+
size_bytes: int | None
|
|
86
|
+
tier: CacheTier | None
|
|
87
|
+
timestamp: float = field(default_factory=time.monotonic)
|
|
88
|
+
reason: str = ""
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@dataclass
|
|
92
|
+
class CacheStats:
|
|
93
|
+
"""Accumulated hit/miss/eviction statistics."""
|
|
94
|
+
hits: int = 0
|
|
95
|
+
misses: int = 0
|
|
96
|
+
admissions: int = 0
|
|
97
|
+
evictions: int = 0
|
|
98
|
+
rejections: int = 0
|
|
99
|
+
promotions: int = 0
|
|
100
|
+
demotions: int = 0
|
|
101
|
+
bytes_evicted: int = 0
|
|
102
|
+
bytes_admitted: int = 0
|
|
103
|
+
|
|
104
|
+
@property
|
|
105
|
+
def hit_rate(self) -> float | None:
|
|
106
|
+
total = self.hits + self.misses
|
|
107
|
+
return self.hits / total if total > 0 else None
|
|
108
|
+
|
|
109
|
+
def to_dict(self) -> dict:
|
|
110
|
+
return {
|
|
111
|
+
"hits": self.hits, "misses": self.misses,
|
|
112
|
+
"admissions": self.admissions, "evictions": self.evictions,
|
|
113
|
+
"rejections": self.rejections,
|
|
114
|
+
"bytes_evicted": self.bytes_evicted,
|
|
115
|
+
"bytes_admitted": self.bytes_admitted,
|
|
116
|
+
"hit_rate": self.hit_rate,
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class CacheManager:
|
|
121
|
+
"""
|
|
122
|
+
Local state cache for one ACR node.
|
|
123
|
+
|
|
124
|
+
Parameters
|
|
125
|
+
----------
|
|
126
|
+
storage : the storage backend that holds actual bytes
|
|
127
|
+
capacity_bytes: soft limit on total cache size; None = unlimited
|
|
128
|
+
eviction_policy : which entry to evict when over capacity
|
|
129
|
+
admission_policy : whether to admit a new entry
|
|
130
|
+
default_tier : which tier admitted entries land in (RAM or STORAGE)
|
|
131
|
+
max_events : how many CacheEvents to retain in the event log
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
def __init__(
|
|
135
|
+
self,
|
|
136
|
+
storage: StorageBackend,
|
|
137
|
+
capacity_bytes: int | None = None,
|
|
138
|
+
eviction_policy: EvictionPolicy | None = None,
|
|
139
|
+
admission_policy: AdmissionPolicy | None = None,
|
|
140
|
+
default_tier: CacheTier = CacheTier.RAM,
|
|
141
|
+
max_events: int = 1000,
|
|
142
|
+
) -> None:
|
|
143
|
+
self._storage = storage
|
|
144
|
+
self.capacity_bytes = capacity_bytes
|
|
145
|
+
self._eviction = eviction_policy or LRUEvictionPolicy()
|
|
146
|
+
self._admission = admission_policy or AlwaysAdmitPolicy()
|
|
147
|
+
self._default_tier = default_tier
|
|
148
|
+
self._max_events = max_events
|
|
149
|
+
|
|
150
|
+
# chunk_id → CacheEntry
|
|
151
|
+
self._entries: dict[str, CacheEntry] = {}
|
|
152
|
+
# chunk_id → CacheTier
|
|
153
|
+
self._tiers: dict[str, CacheTier] = {}
|
|
154
|
+
# Accumulated stats
|
|
155
|
+
self._stats = CacheStats()
|
|
156
|
+
# Event log (bounded)
|
|
157
|
+
self._events: list[CacheEvent] = []
|
|
158
|
+
|
|
159
|
+
# ------------------------------------------------------------------
|
|
160
|
+
# Core operations
|
|
161
|
+
# ------------------------------------------------------------------
|
|
162
|
+
|
|
163
|
+
def put(self, chunk_id: str, data: bytes, priority: int = 0) -> bool:
|
|
164
|
+
"""
|
|
165
|
+
Admit a chunk into the cache.
|
|
166
|
+
|
|
167
|
+
Returns True if admitted, False if rejected by admission policy.
|
|
168
|
+
If the cache is over capacity after admission, eviction is triggered.
|
|
169
|
+
|
|
170
|
+
The data is written to the storage backend on admission.
|
|
171
|
+
"""
|
|
172
|
+
size = len(data)
|
|
173
|
+
|
|
174
|
+
# Admission check
|
|
175
|
+
if not self._admission.should_admit(chunk_id, size):
|
|
176
|
+
self._stats.rejections += 1
|
|
177
|
+
self._emit(CacheEventType.REJECTED, chunk_id, size, None, "admission_policy")
|
|
178
|
+
return False
|
|
179
|
+
|
|
180
|
+
# If already present, update data and refresh entry
|
|
181
|
+
now = time.monotonic()
|
|
182
|
+
if chunk_id in self._entries:
|
|
183
|
+
old_size = self._entries[chunk_id].size_bytes
|
|
184
|
+
self._entries[chunk_id].size_bytes = size
|
|
185
|
+
self._eviction.on_access(self._entries[chunk_id], now)
|
|
186
|
+
key = self._storage_key(chunk_id)
|
|
187
|
+
self._storage.write(key, data)
|
|
188
|
+
self._stats.bytes_admitted += size - old_size
|
|
189
|
+
return True
|
|
190
|
+
|
|
191
|
+
# Write to storage backend
|
|
192
|
+
key = self._storage_key(chunk_id)
|
|
193
|
+
self._storage.write(key, data)
|
|
194
|
+
|
|
195
|
+
entry = CacheEntry(
|
|
196
|
+
chunk_id=chunk_id, size_bytes=size,
|
|
197
|
+
priority=priority, inserted_at=now,
|
|
198
|
+
)
|
|
199
|
+
self._eviction.on_insert(entry, now)
|
|
200
|
+
self._entries[chunk_id] = entry
|
|
201
|
+
self._tiers[chunk_id] = self._default_tier
|
|
202
|
+
|
|
203
|
+
self._stats.admissions += 1
|
|
204
|
+
self._stats.bytes_admitted += size
|
|
205
|
+
self._emit(CacheEventType.ADMITTED, chunk_id, size, self._default_tier)
|
|
206
|
+
|
|
207
|
+
# Evict if over capacity
|
|
208
|
+
self._enforce_capacity()
|
|
209
|
+
return True
|
|
210
|
+
|
|
211
|
+
def get(self, chunk_id: str) -> bytes | None:
|
|
212
|
+
"""
|
|
213
|
+
Retrieve cached chunk bytes.
|
|
214
|
+
Returns None on cache miss (does NOT raise).
|
|
215
|
+
Records hit or miss in stats.
|
|
216
|
+
"""
|
|
217
|
+
if chunk_id not in self._entries:
|
|
218
|
+
self._stats.misses += 1
|
|
219
|
+
self._emit(CacheEventType.MISS, chunk_id, None, None)
|
|
220
|
+
return None
|
|
221
|
+
|
|
222
|
+
entry = self._entries[chunk_id]
|
|
223
|
+
now = time.monotonic()
|
|
224
|
+
self._eviction.on_access(entry, now)
|
|
225
|
+
self._stats.hits += 1
|
|
226
|
+
tier = self._tiers.get(chunk_id, self._default_tier)
|
|
227
|
+
self._emit(CacheEventType.HIT, chunk_id, entry.size_bytes, tier)
|
|
228
|
+
|
|
229
|
+
key = self._storage_key(chunk_id)
|
|
230
|
+
try:
|
|
231
|
+
return self._storage.read(key)
|
|
232
|
+
except KeyError:
|
|
233
|
+
# Metadata says cached but bytes gone — treat as miss, clean up
|
|
234
|
+
self._remove_entry(chunk_id)
|
|
235
|
+
self._stats.hits -= 1
|
|
236
|
+
self._stats.misses += 1
|
|
237
|
+
return None
|
|
238
|
+
|
|
239
|
+
def contains(self, chunk_id: str) -> bool:
|
|
240
|
+
"""Return True if chunk_id is in the cache (metadata check only)."""
|
|
241
|
+
return chunk_id in self._entries
|
|
242
|
+
|
|
243
|
+
def evict(self, chunk_id: str) -> bool:
|
|
244
|
+
"""
|
|
245
|
+
Explicitly evict a specific chunk.
|
|
246
|
+
Returns True if it was in the cache, False otherwise.
|
|
247
|
+
"""
|
|
248
|
+
if chunk_id not in self._entries:
|
|
249
|
+
return False
|
|
250
|
+
size = self._entries[chunk_id].size_bytes
|
|
251
|
+
tier = self._tiers.get(chunk_id)
|
|
252
|
+
self._remove_entry(chunk_id)
|
|
253
|
+
self._stats.evictions += 1
|
|
254
|
+
self._stats.bytes_evicted += size
|
|
255
|
+
self._emit(CacheEventType.EVICTED, chunk_id, size, tier, "explicit_eviction")
|
|
256
|
+
return True
|
|
257
|
+
|
|
258
|
+
def promote(self, chunk_id: str, target_tier: CacheTier) -> bool:
|
|
259
|
+
"""
|
|
260
|
+
Promote a chunk to a higher (lower-number) tier.
|
|
261
|
+
Returns False if chunk not in cache or already at target tier.
|
|
262
|
+
GPU promotions are metadata-only (bytes stay in storage).
|
|
263
|
+
"""
|
|
264
|
+
if chunk_id not in self._entries:
|
|
265
|
+
return False
|
|
266
|
+
current = self._tiers.get(chunk_id, self._default_tier)
|
|
267
|
+
if target_tier.value >= current.value:
|
|
268
|
+
return False # not a promotion
|
|
269
|
+
self._tiers[chunk_id] = target_tier
|
|
270
|
+
self._stats.promotions += 1
|
|
271
|
+
size = self._entries[chunk_id].size_bytes
|
|
272
|
+
self._emit(CacheEventType.PROMOTED, chunk_id, size, target_tier,
|
|
273
|
+
f"{current.name}→{target_tier.name}")
|
|
274
|
+
return True
|
|
275
|
+
|
|
276
|
+
def demote(self, chunk_id: str, target_tier: CacheTier) -> bool:
|
|
277
|
+
"""
|
|
278
|
+
Demote a chunk to a lower (higher-number) tier.
|
|
279
|
+
Returns False if chunk not in cache or already at/below target.
|
|
280
|
+
"""
|
|
281
|
+
if chunk_id not in self._entries:
|
|
282
|
+
return False
|
|
283
|
+
current = self._tiers.get(chunk_id, self._default_tier)
|
|
284
|
+
if target_tier.value <= current.value:
|
|
285
|
+
return False # not a demotion
|
|
286
|
+
self._tiers[chunk_id] = target_tier
|
|
287
|
+
self._stats.demotions += 1
|
|
288
|
+
size = self._entries[chunk_id].size_bytes
|
|
289
|
+
self._emit(CacheEventType.DEMOTED, chunk_id, size, target_tier,
|
|
290
|
+
f"{current.name}→{target_tier.name}")
|
|
291
|
+
return True
|
|
292
|
+
|
|
293
|
+
def prefetch(self, chunk_id: str, data: bytes, priority: int = 1) -> bool:
|
|
294
|
+
"""
|
|
295
|
+
Proactively admit a chunk with a standard priority boost.
|
|
296
|
+
Delegates to put() with a structured event.
|
|
297
|
+
"""
|
|
298
|
+
result = self.put(chunk_id, data, priority=priority)
|
|
299
|
+
if result:
|
|
300
|
+
# Relabel last admitted event as prefetch
|
|
301
|
+
self._emit(CacheEventType.PREFETCH, chunk_id, len(data), self._default_tier)
|
|
302
|
+
return result
|
|
303
|
+
|
|
304
|
+
# ------------------------------------------------------------------
|
|
305
|
+
# Pressure and capacity
|
|
306
|
+
# ------------------------------------------------------------------
|
|
307
|
+
|
|
308
|
+
def current_bytes(self) -> int:
|
|
309
|
+
"""Total bytes in cache (from entry metadata, not storage scan)."""
|
|
310
|
+
return sum(e.size_bytes for e in self._entries.values())
|
|
311
|
+
|
|
312
|
+
def pressure(self) -> float | None:
|
|
313
|
+
"""
|
|
314
|
+
Cache pressure (0.0–1.0).
|
|
315
|
+
Returns None if no capacity limit is set.
|
|
316
|
+
"""
|
|
317
|
+
if self.capacity_bytes is None:
|
|
318
|
+
return None
|
|
319
|
+
return min(1.0, self.current_bytes() / self.capacity_bytes)
|
|
320
|
+
|
|
321
|
+
def entry_count(self) -> int:
|
|
322
|
+
return len(self._entries)
|
|
323
|
+
|
|
324
|
+
def cached_chunk_ids(self) -> set[str]:
|
|
325
|
+
return set(self._entries.keys())
|
|
326
|
+
|
|
327
|
+
def chunks_at_tier(self, tier: CacheTier) -> list[str]:
|
|
328
|
+
return [cid for cid, t in self._tiers.items() if t == tier]
|
|
329
|
+
|
|
330
|
+
def get_tier(self, chunk_id: str) -> CacheTier:
|
|
331
|
+
"""Return the tier of a cached chunk, or REMOTE if not cached."""
|
|
332
|
+
return self._tiers.get(chunk_id, CacheTier.REMOTE)
|
|
333
|
+
|
|
334
|
+
# ------------------------------------------------------------------
|
|
335
|
+
# Stats and observability
|
|
336
|
+
# ------------------------------------------------------------------
|
|
337
|
+
|
|
338
|
+
@property
|
|
339
|
+
def stats(self) -> CacheStats:
|
|
340
|
+
return self._stats
|
|
341
|
+
|
|
342
|
+
def recent_events(self, n: int = 50) -> list[CacheEvent]:
|
|
343
|
+
return self._events[-n:]
|
|
344
|
+
|
|
345
|
+
def reset_stats(self) -> None:
|
|
346
|
+
self._stats = CacheStats()
|
|
347
|
+
|
|
348
|
+
# ------------------------------------------------------------------
|
|
349
|
+
# Private helpers
|
|
350
|
+
# ------------------------------------------------------------------
|
|
351
|
+
|
|
352
|
+
def _storage_key(self, chunk_id: str) -> str:
|
|
353
|
+
return f"cache/{chunk_id}"
|
|
354
|
+
|
|
355
|
+
def _remove_entry(self, chunk_id: str) -> None:
|
|
356
|
+
"""Remove entry metadata and backing storage."""
|
|
357
|
+
self._entries.pop(chunk_id, None)
|
|
358
|
+
self._tiers.pop(chunk_id, None)
|
|
359
|
+
key = self._storage_key(chunk_id)
|
|
360
|
+
self._storage.delete(key)
|
|
361
|
+
|
|
362
|
+
def _enforce_capacity(self) -> None:
|
|
363
|
+
"""Evict entries until we are within capacity, or cache is empty."""
|
|
364
|
+
if self.capacity_bytes is None:
|
|
365
|
+
return
|
|
366
|
+
while self.current_bytes() > self.capacity_bytes and self._entries:
|
|
367
|
+
victim_id = self._eviction.choose_victim(self._entries)
|
|
368
|
+
if victim_id is None:
|
|
369
|
+
break
|
|
370
|
+
size = self._entries[victim_id].size_bytes
|
|
371
|
+
tier = self._tiers.get(victim_id)
|
|
372
|
+
self._remove_entry(victim_id)
|
|
373
|
+
self._stats.evictions += 1
|
|
374
|
+
self._stats.bytes_evicted += size
|
|
375
|
+
self._emit(CacheEventType.EVICTED, victim_id, size, tier, "capacity_pressure")
|
|
376
|
+
|
|
377
|
+
def _emit(
|
|
378
|
+
self,
|
|
379
|
+
event_type: CacheEventType,
|
|
380
|
+
chunk_id: str,
|
|
381
|
+
size_bytes: int | None,
|
|
382
|
+
tier: CacheTier | None,
|
|
383
|
+
reason: str = "",
|
|
384
|
+
) -> None:
|
|
385
|
+
event = CacheEvent(
|
|
386
|
+
event_type=event_type,
|
|
387
|
+
chunk_id=chunk_id,
|
|
388
|
+
size_bytes=size_bytes,
|
|
389
|
+
tier=tier,
|
|
390
|
+
reason=reason,
|
|
391
|
+
)
|
|
392
|
+
self._events.append(event)
|
|
393
|
+
if len(self._events) > self._max_events:
|
|
394
|
+
self._events = self._events[-self._max_events:]
|