"""Reusable goal contract for oracle-backed processor-core campaigns.""" from __future__ import annotations from dataclasses import dataclass from pathlib import Path @dataclass(frozen=True) class ProcessorCoreGoalSpec: campaign_name: str architecture: str package_name: str target: Path interpreter: Path oracle_name: str oracle_repository: str oracle_revision: str oracle_scale: str oracle_sha256: str = "" scope: str = "" def build_processor_core_goal(spec: ProcessorCoreGoalSpec) -> str: """Build the human-reviewable objective saved before roadmap planning.""" scope = spec.scope.strip() or ( f"Implement the complete {spec.architecture} instruction behavior represented by the " "pinned primary oracle. Treat every oracle partition as required unless this objective " "explicitly excludes it." ) hash_line = ( f"- Primary oracle artifact SHA-256: `{spec.oracle_sha256}`." if spec.oracle_sha256 else "- The repository revision is the immutable primary-oracle identity." ) return f"""Build a Python 3.12+ pure-Python {spec.architecture} instruction-core reference implementation for distribution `{spec.campaign_name}` with flat import package `{spec.package_name}`. The result must be readable, dependency-free at runtime, oracle-validated, and embeddable rather than a complete machine. ## Approved execution boundary - Work only in `{spec.target}`. - Use only the target-local interpreter `{spec.interpreter}` for project commands. - Do not read, copy, import, or depend on source or tests from sibling processor-core attempts. - Keep fetched, generated, temporary, and built artifacts inside the target checkout. - Every planned task must fit the campaign ceilings of at most 6 changed files and 400 changed lines. Split larger work in the roadmap rather than exceeding those limits. ## Human-approved scope {scope} Do not add a host-specific memory map, peripherals, video, audio, cartridge, operating system, or complete machine unless the scope above explicitly requires it. Define a small host boundary for memory access and external signal state. Use hatchling, pytest, and Ruff, with no runtime dependencies. ## Immutable primary oracle - Name: `{spec.oracle_name}`. - Repository: `{spec.oracle_repository}`. - Full pinned revision: `{spec.oracle_revision}`. - Verified scale: {spec.oracle_scale}. {hash_line} Use these values directly. Do not spend task turns rediscovering or replacing the approved oracle. Provision it with a project-local, reproducible fetcher, verify the pinned identity before use, keep the checkout ignored by Git, and record the exact revision and hashes in `docs/validation.md`. ## Bounded validation contract - Partition tests at an architecture-sized boundary such as opcode or instruction-family files, and stream records within each test. - Never parametrize one pytest case per raw oracle record. Collection and result storage must stay bounded as the corpus grows. - Use focused partitions during implementation. Any task running the complete corpus must declare a timeout above its measured or conservatively estimated runtime. - Do not use first-record shortcuts, blanket skip/xfail rules, or unsupported-instruction exceptions for behavior included in the approved scope. - Add at least one independent integration exerciser or independently implemented cross-check when one exists, with a finite instruction or time budget and immutable revision/hash metadata. - Final completion requires the entire approved oracle scope, focused tests, full-suite tests, strict Ruff check, strict Ruff format check, clean Git state, and reproducible validation docs. ## Required visible roadmap milestones 1. Package, processor state, host boundary, and bounded oracle provisioning. 2. A representative end-to-end instruction slice proving fetch/decode/execute and oracle comparison. 3. Complete instruction families in explicit countable milestones, including a documented-opcode checkpoint when the architecture distinguishes documented and undocumented behavior. 4. Full primary-oracle completion with zero unexplained exclusions. 5. Independent exerciser/cross-check, public documentation, and release-readiness verification. The roadmap may split these milestones further, but it must preserve their order and make progress visible through durable phase and task counts. Planning, roadmap approval, execution, and final release judgment remain separate operator actions. """.rstrip()