# Heuristic Case Folder Migration Execution State

## Current State

- Status: complete
- Current task: none
- Next task: none
- Last updated: 2026-05-19 CST
- Branch/commit: `feat/heuristic-case-folder-migration`
- Source document: `docs/plans/heuristic-case-folder-migration/heuristic-case-folder-migration-plan.md`

## Task Ledger

| ID | Status | Task | Evidence | Notes |
| --- | --- | --- | --- | --- |
| T1.1 | done | Document the folder schema in HEURISTIC_SYSTEM and inbox READMEs | `HEURISTIC_SYSTEM.md` `## Case Layout`; `heuristic-system/README.md`; `heuristic-system/error-inbox/README.md` `## Case Folder Layout` | Restated the redaction guardrail and the unchanged "Runtime evidence is not automatically a repo artifact" rule. |
| T1.2 | done | Implement the redaction module in the helper | `skills/workflows/heuristic-system/heuristic-error-inbox/bin/heuristic_error_inbox.py` (`redact_ingest_source`, `evidence_violations`, `normalize_home_paths`, `is_raw_skill_usage_record`); helper tests `ingest_evidence_rejects_*` + `ingest_evidence_accepts_*` + `verify_rejects_*` | Rules: reject raw `skill-usage.record.json` (by filename or schema sniff), token-like patterns (`Bearer`, `token=`, `api_key=`, `-----BEGIN`, password/credential `=`), oversize files (default 64 KiB), un-normalized `$HOME` paths (`/Users/<user>`, `/home/<user>`). |
| T1.3 | done | Add folder-aware helper subcommands | helper diff (`resolve_case`, `iter_cases`, `iter_archived_inbox_cases`, `Case`); `ingest-evidence` subcommand; `archive` moves the whole folder; `set-status`/`verify`/`archive` accept folder or `ENTRY.md` path; `verify` also accepts `RECORD.md` | Operation records validate against `RECORD_REQUIRED_SECTIONS`; per the plan, `new`/`set-status`/`archive` remain inbox-only. |
| T2.1 | done | Migrate the archived inbox entry to folder shape | `git mv heuristic-system/error-inbox/archive/2026/deliver-gitlab-mr-skipped-pipeline-and-cleanup.md heuristic-system/error-inbox/archive/2026/deliver-gitlab-mr-skipped-pipeline-and-cleanup/ENTRY.md`; helper `verify` ok | Historical lifecycle text preserved; no `evidence/` files added. |
| T2.2 | done | Migrate the operation record to folder shape | `git mv heuristic-system/operation-records/github-pr-required-check-gating.md heuristic-system/operation-records/github-pr-required-check-gating/RECORD.md`; helper `verify` ok (kind=record) | Validation commands kept inline; no `evidence/` artifacts added because the existing record links remote URLs that should not be embedded. |
| T2.3 | done | Update sibling tooling and docs references | `tests/script_specs/skills/workflows/heuristic-system/heuristic-error-inbox/scripts/heuristic-error-inbox.sh.json` (help regex now lists `ingest-evidence`; `verify` and `list --include-archived` point at the folder shape) | `docs-plan-cleanup.sh` path matchers already use directory prefixes (`heuristic-system/error-inbox/*`, `heuristic-system/operation-records/*`), so they pick up folder cases without changes; `docs-plan-cleanup` + `durable-artifact-cleanup` tests still pass. |
| T3.1 | done | Run focused gates and audit committed evidence | `scripts/check.sh --tests -- -k "heuristic_system or heuristic_error_inbox"`: 35 passed; `grep -rE 'Bearer\\s+\\S{16,}\|sk-\\S{16,}\|api[_-]?key\\s*[:=]\\s*\\S{16,}\|-----BEGIN' heuristic-system/`: 0 matches; `find heuristic-system -type f -size +64k`: empty; `find heuristic-system -name skill-usage.record.json`: empty | No token-like content or oversize files committed. |
| T3.2 | done | Run the full repo gate and prepare delivery | `scripts/check.sh --all`: pass, 831 pytest tests passed | First run flagged stale script-smoke regexes; fixed by updating the spec to list the new `ingest-evidence` verb and point at folder paths, then re-ran clean. |

## Validation

| Command | Status | Summary | Artifact |
| --- | --- | --- | --- |
| `agent-docs --docs-home "$HOME/.claude" resolve --context startup --strict --format checklist` | warn | Pre-existing gap (missing `~/.claude/CODEX_AGENTS.md` and `~/.claude/docs/runbooks/agent-docs/MEMORY_USAGE.md`); user opted to proceed across this plan series. | n/a |
| `scripts/check.sh --tests -- -k "heuristic_system or heuristic_error_inbox"` | pass | 35 targeted tests passed (incl. new redaction + ingest-evidence + folder-shape coverage). | `/Users/terry/.agents/out/tests/script-coverage/summary.md` |
| `scripts/check.sh --tests -- -k "docs_plan_cleanup or durable_artifact_cleanup"` | pass | 12 sibling tooling tests passed; folder shape did not regress path matchers. | `/Users/terry/.agents/out/tests/script-coverage/summary.md` |
| `scripts/check.sh --markdown` | pass | Markdown lint passed for 272 files (incl. migrated `ENTRY.md` / `RECORD.md`). | n/a |
| `plan-tooling validate --file docs/plans/heuristic-case-folder-migration/heuristic-case-folder-migration-plan.md` | pass | Plan structure validated. | n/a |
| `heuristic-error-inbox.sh verify heuristic-system/error-inbox/archive/2026/deliver-gitlab-mr-skipped-pipeline-and-cleanup/` | pass | Migrated archived case validates with `ok: true`, status=`promoted`. | n/a |
| `heuristic-error-inbox.sh verify heuristic-system/operation-records/github-pr-required-check-gating/` | pass | Migrated operation record validates with `ok: true`, kind=`record`. | n/a |
| `scripts/check.sh --all` | pass | Full local gate passed; 831 pytest tests passed. | `/tmp/check-all-pr2.log` |

## Blockers

- None.

## Session Log

### 2026-05-19 CST

- Read:
  - `docs/plans/heuristic-case-folder-migration/heuristic-case-folder-migration-plan.md`
  - `docs/plans/heuristic-case-folder-migration/heuristic-case-folder-migration-discussion-source.md`
  - `HEURISTIC_SYSTEM.md`
  - `heuristic-system/README.md`
  - `heuristic-system/error-inbox/README.md`
  - `heuristic-system/error-inbox/archive/2026/deliver-gitlab-mr-skipped-pipeline-and-cleanup.md`
  - `heuristic-system/operation-records/github-pr-required-check-gating.md`
  - `skills/workflows/heuristic-system/heuristic-error-inbox/SKILL.md`
  - `skills/workflows/heuristic-system/heuristic-error-inbox/bin/heuristic_error_inbox.py`
  - `skills/workflows/heuristic-system/heuristic-error-inbox/tests/test_workflows_heuristic_system_heuristic_error_inbox.py`
  - `skills/workflows/plan/docs-plan-cleanup/scripts/docs-plan-cleanup.sh`
  - `skills/workflows/plan/docs-plan-cleanup/tests/test_docs_plan_cleanup.sh`
  - `skills/workflows/plan/durable-artifact-cleanup/SKILL.md`
  - `tests/script_specs/skills/workflows/heuristic-system/heuristic-error-inbox/scripts/heuristic-error-inbox.sh.json`
  - `tests/test_heuristic_system_docs.py`
- Edits: see Task Ledger T1.1–T3.2.
- Validation: see Validation table.

## Open Questions Resolved

- Plans stay in `docs/plans/<slug>/`; case folders may reference but not embed
  plans. Confirmed during execution; no real case prompted divergence.
- Redaction is a `--max-bytes` flag plus implicit guardrail on
  `ingest-evidence`, not a separate `redact` subcommand. Confirmed during
  execution; the `--force` and `--label`/`--suffix` flags handle the
  documented escape hatch (manual review then overwrite).

## Retention Intent

Execution-state for plan delivery; cleanup-eligible after the matching PR
merges and the durable docs reflect the new shape.
