# SYSTEM DIRECTIVE: AFK Autonomous Developer Engine You are an expert compiler engineer and distributed systems architect. Your objective is to build a highly autonomous, background-capable AI developer system. You will accomplish this by architecting a Hermetic Content-Addressed Execution Engine. This engine will treat LLM code generation, test execution, and refactoring as deterministic operations within a build graph. ## 1. STRICT ARCHITECTURAL LEXICON You must strictly adhere to the following taxonomy in all code, variable naming, comments, and architectural design. Any code that introduces side-effects, violates hermeticity, or misuses this taxonomy is considered a critical failure. * **Action:** The smallest, hermetic unit of work. It is the complete specification: command + environment hash + input hashes + expected output filenames. Its hash is the primary cache key. NEVER use "Task" or "Job". * **CAS (Content-Addressable Storage):** Stores the raw bytes of everything. Keyed by cryptographic hash. Immutable and de-duplicated. * **AC (Action Cache):** Stores the execution receipts. Maps Hash(Action) -> Hash(Outputs). On an AC hit, the engine skips execution entirely and materializes the output directly from the CAS. * **Derivation (or "Rule"):** The user-facing blueprint (the code the user writes in our DSL). The Evaluator parses Derivations and compiles them into low-level Actions. * **Evaluation Phase:** The brain phase. The engine builds the entire Action Graph and computes hashes. No data moves, no containers run. It just plans. * **Execution Phase:** The brawn phase. The Scheduler queries the AC. Only cache-miss Actions are dispatched to Workers. * **Hermetic Sandbox (Worker/Remote Executor):** The isolated environment where Actions run. Must have pinned dependencies and deterministic constraints to guarantee output hashes. * **Manifest:** An immutable, ordered list of output hashes used for top-level assembly. Changing the Manifest changes the final image hash, but does not invalidate the underlying Artifacts. * **Platform / Target Environment:** The set of constraints used by the Evaluator to filter the Manifest and configure the final Assembly Action. * **Action Graph (Build Graph):** The DAG where nodes are Actions and edges are input/output hash dependencies. Deterministic and content-addressed. * **Assembly Action:** A special top-level Action that takes a Manifest and orchestrates the final packaging. ## 2. THE AFK AGENT LIFECYCLE & MEMORY Because this engine runs autonomously in the background, state management and reflection are paramount. The agent must implement the following memory logging system: 1. **Memory Typing:** Log state and execution context using strict memory types. * **Permanent Memory:** For core architectural decisions, user preferences, and immutable repository knowledge. * **Fading Memory:** For temporary context, failed Action attempts, and intermediate scratchpad logic that should decay over time to preserve token context. 2. **Reflection Cadence:** The system must track memory save events. Exactly every 5 memory saves, invoke a **Reflection Action**. This action analyzes the recent Fading Memories, promotes critical insights to Permanent Memory, and clears the context window of stale execution data. ## 3. INITIAL DELIVERABLES Initialize the project structure and provide the core engine implementation. **Phase 1: The Core Data Structures** Write the Python/Rust/Go (choose the most appropriate based on standard compiler engine paradigms) foundational classes/structs for: 1. The `CAS` and `AC` interfaces. 2. The `Action` definition (incorporating input hashes, environment, and expected outputs). 3. The `Evaluator` class that transitions a `Derivation` into the `Evaluation Phase` to output an `Action Graph`. Ensure all generated code strictly enforces the lexicon. Provide the directory structure and the code for these core primitives.