# Codex Fix Patches Artifact Lifecycle Instruction Instruction ID: fix-patches-artifact-lifecycle-v1 Version: v1 Target Agent: codex ## Objective Manage the lifecycle of artifacts in the `patches/` directory — specifically, clean up stale or committed artifacts (`.branch.json`, `nl/*.json`, standalone `.json` patch files) that are no longer needed. ## Background The ChatGPT Actions API writes several types of artifacts into `patches/`: 1. **Branch metadata** (`patches/patch_*.branch.json`) — created when the `branch()` action writes ahead. These are summary records of created branches. 2. **Patch files** (`patches/*.json`, top level) — created when the `patch()` action saves a JSON patch proposal. Example: `patches/self-evolution-agent-orchestration-policy.json`. 3. **Natural language plan files** (`patches/nl/nl-*.json`) — created when `nl()` action records a natural-language plan. These are transient planning artifacts. None of these files represent durable long-term state. Once committed, they are snapshots of ephemeral decisions. The `patches/` directory should not grow unboundedly with stale artifacts. ## Preconditions - GitOps authentication healthy. - Current working branch should not be diverging from main unnecessarily for this cleanup. - Run from the workspace root. ## Steps ### Phase 1: Assess Current State 1. List all files under `patches/`. 2. For each file, check its git log (`git log --oneline patches/`) to understand its purpose and age. 3. Identify which files are: - Stale `.branch.json` files describing branches that have already been merged. - Stale `nl/` plan files that were experimental, incomplete, or superseded. - Patch files that are still relevant for the current self-evolution state. ### Phase 2: Clean Up Stale Artifacts For each stale artifact file: 1. Remove it with `git rm`. 2. Create a single commit message describing the batch cleanup, e.g.: `chore(patches): remove stale artifact files [nl/*.json|branch.json]` ### Phase 3: Housekeeping (Optional) If the file `self-evolution-agent-orchestration-policy.json` in patches/ is superseded by the active `config/self-evolution/agent-orchestration-policy.json`, evaluate whether it should also be removed or kept as reference. Document this decision. ## Constraints - No force push. - No direct production publish. - No secret output. - Preserve audit trail. - Only remove files that are confirmed stale (do not remove actively referenced patches that the runtime still uses to bootstrap state). ## Return Format Status: Workspace: Branch: Files Removed: Files Kept: Commit: Issues: