# Agrarian Build Log Retention Policy

This policy covers generated build, package, cook, editor, crash, shader, and
automation logs for the Agrarian Unreal project.

## Goals

- Keep enough recent logs to debug build and packaging failures.
- Preserve important release/investor-demo logs long enough to explain what was
  shipped.
- Prevent `Saved/`, `Builds/`, and generated automation output from growing
  without limit on the shared project drive.
- Keep generated logs out of Git.

## Log Locations

- `Saved/BuildLogs/`: Windows editor builds, packaged target builds, and
  packaging logs.
- `Saved/Logs/`: Unreal editor, cook, runtime, UnrealPak, World Partition, and
  commandlet logs.
- `Saved/Crashes/`: editor/runtime crash context, logs, and dumps.
- `Saved/MaterialStats/`: generated material stat CSV files.
- `Saved/Shaders/` and `Saved/ShaderDebugInfo/`: generated shader diagnostics.
- `Builds/`: packaged local build outputs. These are not retained as source
  artifacts unless explicitly published or sent externally.

## Default Retention

- Build/package logs in `Saved/BuildLogs/`: keep 90 days.
- Unreal logs in `Saved/Logs/`: keep 30 days.
- Crash reports in `Saved/Crashes/`: keep 90 days.
- Material stats in `Saved/MaterialStats/`: keep 30 days.
- Shader debug output in `Saved/Shaders/` and `Saved/ShaderDebugInfo/`: keep 14
  days.
- Local packaged builds in `Builds/`: keep the latest published investor/demo
  package and any active test build; prune older regenerated builds manually.

## Preserve Before Pruning

Before deleting logs, preserve any file that is tied to:

- an investor/demo package;
- a release candidate;
- a crash or build failure still being investigated;
- a bug report sent to another person;
- a store upload or external test distribution.

Preserved logs should be copied to a dated folder under a local operational
archive or attached to the related issue/release note before cleanup.

## Cleanup Script

Use:

```text
Scripts/prune_build_logs.sh --dry-run
Scripts/prune_build_logs.sh --apply
```

The script is dry-run by default. It only removes generated files under known
`Saved/` log/debug paths and empty directories left behind. It does not touch
source, `Content/`, `Config/`, `Source/`, `Docs/`, or Git history.

## Cadence

- Run dry-run before major packaging cycles if the shared drive is getting full.
- Run apply monthly during active development.
- Always run dry-run first when preparing an investor or external test build.

## Git Policy

Generated logs are not committed. Commit only:

- build scripts;
- packaging scripts;
- retention policy docs;
- release notes;
- summaries of important failures or fixes.
