prvng_core/nulib/lib_provisioning/cache/agent.nu
Jesús Pérez 95b2f72ab0
refactor(cache/coredns/extensions/vm): selective imports — 6 files (ADR-025 L2)
Combined batch of 6 L2 refactors. Same mechanical pattern (star -> selective);
grouped in one commit because batch 1 was staged but not committed before
batch 2 was prepared.

=== extensions/commands.nu (4 stars -> 1 selective, 3 dead) ===
  loader_oci.nu [load-extension] (kept, already selective)
  discovery.nu  [4 symbols]
  cache.nu / versions.nu / utils/logging.nu  DROPPED (dead)

=== coredns/commands.nu (4 stars -> 3 selective, 2 dead + 1 broken) ===
  config/loader.nu [get-config] (already selective; promoted to absolute)
  service.nu  [8 symbols]
  zones.nu    [9 symbols]
  corefile.nu [2 symbols]
  utils/log.nu         REMOVED (file does not exist — dangling import)
  utils/logging.nu     DROPPED (dead)

=== cache/agent.nu (4 stars -> 2 selective, 2 dead) ===
  cache_manager.nu [4 symbols]
  batch_updater.nu [2 symbols]
  version_loader.nu / grace_checker.nu  DROPPED (dead)

=== vm/vm_persistence.nu (3 stars -> 2 selective, 1 dead) ===
  result.nu        [6 symbols]
  vm/lifecycle.nu  [vm-delete]
  vm/persistence.nu  DROPPED (dead)

=== vm/nested_provisioning.nu (3 stars -> 3 selective) ===
  vm/lifecycle.nu            [vm-info]
  vm/volume_management.nu    [volume-attach volume-detach]
  vm/network_management.nu   [network-connect network-disconnect]

=== vm/cleanup_scheduler.nu (3 stars -> 1 selective, 1 dead) ===
  vm/vm_persistence.nu [4 symbols]
  vm/lifecycle.nu      DROPPED (dead)
  Note: line ~211 embeds an intentional template string containing
  `use lib_provisioning/vm/cleanup_scheduler.nu *` — it's Nu script code
  written to disk at runtime for the scheduler daemon. NOT a real import.

Validation (ide-check 50 errors after vs baseline):
  extensions/commands.nu   0 vs 0    ✓
  coredns/commands.nu      50 vs 50  ✓ (pre-existing transitive noise)
  cache/agent.nu           0 vs 0    ✓
  vm/vm_persistence.nu     50 vs 50  ✓
  vm/nested_provisioning.nu 50 vs 50 ✓
  vm/cleanup_scheduler.nu  50 vs 50  ✓

21 star-imports eliminated (~10% of remaining 221).

Refs: ADR-025
2026-04-17 08:47:32 +01:00

65 lines
2 KiB
Text
Executable file

#!/usr/bin/env nu
# Dynamic Version Cache Agent
# Token-optimized agent for progressive version caching with infra-aware hierarchy
# Usage: nu agent.nu <command> [args]
# Selective imports (ADR-025 Phase 3 Layer 2).
# version_loader and grace_checker star-imports were dead — dropped.
use lib_provisioning/cache/cache_manager.nu [
clear-cache-system get-cached-version init-cache-system show-cache-status
]
use lib_provisioning/cache/batch_updater.nu [batch-update-cache sync-cache-from-sources]
# Main agent entry point
def main [
command: string # Command: init, get, update-all, clear, status
...args # Additional arguments
] {
match $command {
"init" => {
print "🚀 Initializing dynamic version cache system..."
init-cache-system
print "✅ Cache system initialized"
}
"get" => {
if ($args | length) == 0 {
print "❌ Usage: agent.nu get <component-name>"
exit 1
}
let component = ($args | get 0)
print $"🔍 Getting version for ($component)..."
let version = (get-cached-version $component)
print $"📦 ($component): ($version)"
}
"update-all" => {
print "🔄 Updating all cached versions..."
batch-update-cache
print "✅ Cache updated"
}
"clear" => {
print "🗑️ Clearing version cache..."
clear-cache-system
print "✅ Cache cleared"
}
"status" => {
print "📊 Version cache status:"
show-cache-status
}
"sync" => {
print "🔄 Syncing cache from sources..."
sync-cache-from-sources
print "✅ Cache synced"
}
_ => {
print $"❌ Unknown command: ($command)"
print "Available commands: init, get, update-all, clear, status, sync"
exit 1
}
}
}