1 agents

source-archive-specialist

source-archive-specialist

Overview

The Source Archive Specialist is an L3 agent operating in the domain domain of the Prismatic Platform. This agent creates optimized code packages, manages source code archival processes, and ensures that the platform's codebase is properly packaged for distribution, backup, and historical preservation. In a platform with 90 umbrella applications and over 2.8 million lines of code, systematic source archival is not merely a convenience but a critical operational requirement for disaster recovery, audit compliance, and knowledge preservation.

Source code archival extends beyond simple backup. The Source Archive Specialist understands the semantic structure of the codebase, creating intelligent archives that preserve not just files but their relationships, dependencies, compilation artifacts, and historical context. This enables precise point-in-time reconstruction of any version of the platform, supporting both regulatory compliance requirements and the platform's self-evolution capabilities.

This agent is part of the platform's 434-strong autonomous agent ecosystem, operating under AIAD standard compliance and enforcing the NO MERCY doctrine for archive integrity.

Core Responsibilities

ResponsibilityDescriptionFrequency
Code PackagingCreate optimized release packages for deploymentPer release
Archive GenerationGenerate compressed, deduplicated source archivesDaily
Dependency BundlingPackage dependencies with exact version locksPer release
Historical SnapshotsMaintain point-in-time codebase snapshotsWeekly
Integrity VerificationValidate archive checksums and completenessContinuous
Cleanup ManagementPrune old archives according to retention policyMonthly
Audit TrailMaintain provenance records for all archivesContinuous

Archive Architecture

The Source Archive Specialist maintains a multi-tier archive architecture that balances storage efficiency with retrieval speed.

Tier 1: Hot Archives (Current + Last 7 days)
├── Full source packages with compiled artifacts
├── Immediately accessible for rollback
└── Stored on high-performance storage

Tier 2: Warm Archives (Last 30 days)
├── Source-only packages (no compiled artifacts)
├── Available within minutes for reconstruction
└── Stored on standard storage

Tier 3: Cold Archives (Last 365 days)
├── Compressed, deduplicated archives
├── Available within hours for reconstruction
└── Stored on archival storage

Tier 4: Deep Archives (Historical)
├── Maximum compression, minimum redundancy
├── Available within days for reconstruction
└── Stored on long-term archival storage
TierRetentionCompressionRetrieval TimeStorage Cost
Hot7 daysNoneInstantHigh
Warm30 daysgzipMinutesMedium
Cold365 dayszstd (max)HoursLow
DeepIndefinitezstd + dedupDaysMinimal

Technical Implementation

defmodule PrismaticAgents.SourceArchiveSpecialist do
  @moduledoc """
  L3 Source Archive Specialist agent.
  Creates optimized code packages and manages source archival.
  """

  use GenServer
  require Logger

  @archive_check_interval_ms :timer.hours(6)

  defstruct [
    :last_archive_at,
    :archive_inventory,
    :storage_metrics,
    :integrity_status,
    status: :monitoring
  ]

  @spec start_link(keyword()) :: GenServer.on_start()
  def start_link(opts \\ []) do
    GenServer.start_link(__MODULE__, opts, name: __MODULE__)
  end

  @impl true
  def init(_opts) do
    schedule_archive_check()
    {:ok, %__MODULE__{archive_inventory: load_inventory()}}
  end

  @impl true
  def handle_info(:archive_check, state) do
    integrity = verify_archive_integrity(state.archive_inventory)
    storage = calculate_storage_metrics(state.archive_inventory)

    :telemetry.execute(
      [:prismatic, :agents, :source_archive, :check],
      %{archives_verified: length(integrity.verified), issues: length(integrity.issues)},
      %{total_storage_mb: storage.total_mb}
    )

    schedule_archive_check()

    {:noreply, %{state |
      integrity_status: integrity,
      storage_metrics: storage,
      last_archive_at: DateTime.utc_now()
    }}
  end

  @spec create_release_package(String.t(), keyword()) :: {:ok, map()} | {:error, term()}
  def create_release_package(version, opts \\ []) do
    include_deps = Keyword.get(opts, :include_deps, true)
    compression = Keyword.get(opts, :compression, :zstd)

    with {:ok, files} <- collect_source_files(),
         {:ok, deps} <- if(include_deps, do: collect_dependencies(), else: {:ok, []}),
         {:ok, archive} <- create_archive(files ++ deps, version, compression),
         {:ok, checksum} <- calculate_checksum(archive) do
      {:ok, %{
        version: version,
        path: archive,
        checksum: checksum,
        file_count: length(files) + length(deps),
        created_at: DateTime.utc_now()
      }}
    end
  end
end

Package Types

The Source Archive Specialist produces several types of code packages, each optimized for its specific use case.

Package TypeContentsSizeUse Case
Release PackageCompiled BEAM files, config, scripts~50 MBProduction deployment
Source PackageAll .ex, .exs, config, docs~120 MBDevelopment distribution
Full ArchiveSource + deps + compiled + docs~300 MBComplete backup
Minimal ArchiveCore source only, no deps~40 MBCode review, audit
Delta PackageChanges since last archive~1-10 MBIncremental backup

Integrity Verification

Every archive produced by the Source Archive Specialist includes cryptographic integrity verification to detect corruption or tampering.

Verification MethodAlgorithmScopeFrequency
File ChecksumSHA-256Individual filesAt creation
Archive ChecksumSHA-512Complete archiveAt creation + daily
Manifest VerificationHMAC-SHA-256File listingAt creation + weekly
Cross-ReferenceMerkle treeArchive setMonthly

Storage Metrics

MetricCurrentTarget
Total archive storage2.4 GB< 5 GB
Archive count156Managed by retention
Average archive size15.4 MB< 50 MB
Deduplication ratio78%> 70%
Integrity check pass rate100%100%

Retention Policy Management

The Source Archive Specialist enforces a structured retention policy that balances storage costs against the need for historical reconstruction capability. Different archive tiers follow different retention schedules, with automatic promotion and demotion between tiers as archives age.

Policy RuleApplicationAutomation
7-Day Hot WindowAll archives remain in hot tier for first 7 daysAutomatic demotion to warm on day 8
30-Day Warm RetentionWarm archives retained for 30 days before cold migrationAutomatic compression and migration
365-Day Cold RetentionCold archives retained for one yearAnnual review for deep archive migration
Indefinite Deep StorageMilestone releases and tagged versions kept permanentlyManual tagging by Strategic Command
Emergency PreservationAny archive can be frozen to prevent automatic deletionManual freeze by L2+ authority
Regulatory ComplianceArchives related to compliance reports retained 7 yearsAutomatic compliance tagging

Archive Reconstruction Verification

The Source Archive Specialist periodically verifies that archived packages can be successfully reconstructed into a working development environment. This verification catches subtle corruption issues that checksum verification alone cannot detect.

defmodule PrismaticAgents.SourceArchiveSpecialist.ReconstructionVerifier do
  @moduledoc """
  Verifies that archived packages can be fully reconstructed
  into working development environments.
  """

  @spec verify_reconstruction(String.t()) :: {:ok, map()} | {:error, term()}
  def verify_reconstruction(archive_path) do
    temp_dir = create_temp_workspace()

    with {:ok, _} <- extract_archive(archive_path, temp_dir),
         {:ok, _} <- verify_file_completeness(temp_dir),
         {:ok, _} <- verify_dependency_resolution(temp_dir),
         {:ok, compile_result} <- attempt_compilation(temp_dir),
         {:ok, _} <- verify_test_execution(temp_dir) do
      cleanup_workspace(temp_dir)

      {:ok, %{
        archive: archive_path,
        files_verified: compile_result.file_count,
        compilation: :success,
        tests: :passed,
        verified_at: DateTime.utc_now()
      }}
    else
      {:error, reason} ->
        cleanup_workspace(temp_dir)
        {:error, %{archive: archive_path, failure: reason}}
    end
  end
end
Verification CheckFrequencyScopePass Rate Target
Hot Archive ReconstructionWeeklyLatest 3 archives100%
Warm Archive ReconstructionMonthlyRandom sample of 5100%
Cold Archive ReconstructionQuarterlyRandom sample of 3100%
Deep Archive ReconstructionAnnuallyAll milestone archives100%

Integration Points

AIAD Specification Compliance

AIAD ComponentStatus
Agent specification fileCompliant
Behavioral rules8 rules defined
Telemetry integrationFull coverage
NM/ND doctrine enforcementActive
SEADF integrationRegistered

Disaster Recovery Integration

The Source Archive Specialist plays a critical role in the platform's disaster recovery strategy. In the event of a catastrophic failure -- data center loss, repository corruption, or supply chain attack -- the archive system provides the foundation for rapid platform reconstruction.

Recovery ScenarioArchive Tier UsedRecovery Time ObjectiveRecovery Point Objective
Repository CorruptionHot (Tier 1)< 1 hour< 1 day
Build System FailureHot (Tier 1)< 2 hours< 1 day
Data Center LossWarm (Tier 2)< 8 hours< 7 days
Compliance AuditCold/Deep (Tier 3-4)< 24 hoursPoint-in-time
Historical InvestigationDeep (Tier 4)< 72 hoursSpecific version

Authority Level

L3 - Strategic Command - Multi-domain coordination with authority to create, manage, and verify source code archives across the entire platform.


Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL