Skip to content

Commit 9650974

Browse files
committed
♻️ refactor(app): move follow-import example maintenance into tests
1 parent 13f32c9 commit 9650974

10 files changed

Lines changed: 772 additions & 463 deletions

docs/go/maintainer/development-tracker.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,34 @@ Immediate next tasks:
151151

152152
### 2026-03-17 Session Update
153153

154+
- Completed: Removed the maintainer-only `--list-examples` / `--refresh-examples` execution path from the production `cleanup-follow-imports` and `audit-follow-imports` commands. Hygiene example catalogs now live only in `internal/app/follow_examples_test.go`, checked-in fixture rewrites happen through env-gated test helpers, and the operator/maintainer docs now describe that test-driven maintenance flow instead of advertising unsupported runtime flags.
155+
- In progress: none.
156+
- Blockers: none.
157+
- Next step: decide whether the remaining cleanup/audit flag parsing should also move behind a smaller shared helper, or whether the next slice should return to a new operator-facing capability.
158+
159+
### 2026-03-17 Session Update
160+
161+
- Completed: Extended the shared follow/import example helper to cover example-mode flag parsing and validation as well as fixture IO. `cleanup-follow-imports` and `audit-follow-imports` now reuse the same `--list-examples` / `--refresh-examples[=<name[,name...]>]` parsing, duplicate-name normalization, incompatibility checks, and named-fixture validation, leaving only command-specific operational-target validation in `internal/app/import_follow.go`.
162+
- In progress: none.
163+
- Blockers: none.
164+
- Next step: decide whether the remaining cleanup/audit option-parsing duplication is worth another shared helper, or whether follow/import work should pivot back to new operator-facing functionality.
165+
166+
### 2026-03-17 Session Update
167+
168+
- Completed: Refactored the follow/import example-fixture workflow behind a shared helper in `internal/app/follow_examples.go`. `cleanup-follow-imports` and `audit-follow-imports` now reuse the same base-dir resolution, example-name parsing, named fixture selection, list output, and refresh-writing logic instead of carrying two near-identical helper stacks, while keeping their command-specific example catalogs and renderers unchanged.
169+
- In progress: none.
170+
- Blockers: none.
171+
- Next step: decide whether the current shared helper plus hard-coded example catalogs is the right steady state, or whether a later slice should move those example catalogs into a small manifest once the operator sample set grows further.
172+
173+
### 2026-03-17 Session Update
174+
175+
- Completed: Added checked-in `audit-follow-imports` sample outputs under `internal/app/testdata` together with `--list-examples` and `--refresh-examples[=<name[,name...]>]` maintenance helpers. The audit command now matches the cleanup command's fixture workflow, app and parser coverage verify example-mode parsing plus refresh/list wiring, and `TestAuditFollowImportsExampleOutputsStayInSync` fails if future audit renderer changes are not reflected in the checked-in fixtures and docs.
176+
- In progress: none.
177+
- Blockers: none.
178+
- Next step: decide whether the audit example catalog is complete enough now, or whether future follow/import operator samples should move into a small manifest once the hard-coded fixture set grows further.
179+
180+
### 2026-03-17 Session Update
181+
154182
- Completed: Added `--policy-profile` presets to `scripts/readiness-check` with initial `ci` and `release` profiles. Profiles expand to the existing threshold and warning-policy flags instead of introducing a second policy engine: `ci` sets the current slow-run thresholds, while `release` adds the stale follow-health failure policy on top. Explicit flags still override profile thresholds and append extra warning codes, and the final text/JSON outputs now expose `policy_profile` alongside the already-expanded thresholds and warning-policy fields. Tests now cover profile parsing, override behavior, lint is clean again, and `go test ./...` remains green.
155183
- In progress: none.
156184
- Blockers: none.

docs/go/maintainer/mcp-integration.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,20 +235,35 @@ That combined check now covers:
235235
2. stdio MCP smoke test
236236
3. HTTP MCP smoke test
237237

238-
The checked-in `cleanup-follow-imports` example outputs under [../../../internal/app/testdata](../../../internal/app/testdata/) now support the same maintainer loop. When the cleanup text or JSON renderer changes on purpose, refresh every cleanup fixture from the repository root with:
238+
The checked-in `cleanup-follow-imports` and `audit-follow-imports` example outputs under [../../../internal/app/testdata](../../../internal/app/testdata/) still support a maintainer refresh loop, but that loop now lives only in test code so the packaged commands stay production-focused. When a hygiene-report renderer changes on purpose, refresh every cleanup fixture from the repository root with:
239239

240240
```powershell
241-
go run ./cmd/codex-mem cleanup-follow-imports --refresh-examples
241+
$env:CODEX_MEM_REFRESH_CLEANUP_EXAMPLES = "all"
242+
go test ./internal/app -run TestRefreshCleanupFollowImportsExampleFixtures
243+
Remove-Item Env:CODEX_MEM_REFRESH_CLEANUP_EXAMPLES
242244
```
243245

244-
If you only need a subset while iterating, list the current names first and then refresh the exact fixtures you touched:
246+
Refresh every audit fixture the same way:
245247

246248
```powershell
247-
go run ./cmd/codex-mem cleanup-follow-imports --list-examples
248-
go run ./cmd/codex-mem cleanup-follow-imports --refresh-examples=filtered-cleanup-json
249+
$env:CODEX_MEM_REFRESH_AUDIT_EXAMPLES = "all"
250+
go test ./internal/app -run TestRefreshAuditFollowImportsExampleFixtures
251+
Remove-Item Env:CODEX_MEM_REFRESH_AUDIT_EXAMPLES
249252
```
250253

251-
Then rerun `go test ./internal/app -run TestCleanupFollowImportsExampleOutputsStayInSync` plus the normal repo checks so the updated cleanup fixtures are verified in read-only mode again.
254+
If you only need a subset while iterating, pass the exact fixture names through the matching environment variable. The canonical names live in [../../../internal/app/follow_examples_test.go](../../../internal/app/follow_examples_test.go):
255+
256+
```powershell
257+
$env:CODEX_MEM_REFRESH_CLEANUP_EXAMPLES = "filtered-cleanup-json"
258+
go test ./internal/app -run TestRefreshCleanupFollowImportsExampleFixtures
259+
Remove-Item Env:CODEX_MEM_REFRESH_CLEANUP_EXAMPLES
260+
261+
$env:CODEX_MEM_REFRESH_AUDIT_EXAMPLES = "filtered-audit-json"
262+
go test ./internal/app -run TestRefreshAuditFollowImportsExampleFixtures
263+
Remove-Item Env:CODEX_MEM_REFRESH_AUDIT_EXAMPLES
264+
```
265+
266+
Then rerun `go test ./internal/app -run "Test(Audit|Cleanup)FollowImportsExampleOutputsStayInSync"` plus the normal repo checks so the updated hygiene fixtures are verified in read-only mode again.
252267

253268
The default text summary from `scripts/readiness-check` echoes the `doctor.follow_imports` fields as flat `doctor_follow_imports_*` lines so CI or local automation can inspect last-known runtime watch health from the existing sidecar without having to parse the full doctor JSON again. The helper also emits explicit overall `started_at`, `completed_at`, and `duration_ms` fields plus per-phase `phase_*_status`, `phase_*_summary`, and timing lines for the `doctor`, stdio smoke, and HTTP smoke phases, so a failed run still tells automation which phase stopped progress and how long both the whole run and each attempted phase took before the command exits non-zero. `--json` returns one structured summary object that embeds the parsed doctor report, compact stdio/HTTP smoke-test summaries, and the same overall plus per-phase timing results. `--keep-going` keeps attempting later phases after an earlier failure, which is useful when you want one failing run to still capture as much phase state as possible. `--slow-run-ms` and `--slow-phase-ms` add explicit readiness warnings to both text and JSON output when thresholds are exceeded, `--fail-on-warning-code` lets automation promote selected warning codes, including nested doctor follow-health warning codes, into a failed readiness result, and `--policy-profile` expands a small set of documented presets into those same underlying options while still exposing the final thresholds and warning-policy state in the output. In all modes the follow-health fields are informational by default unless your own automation explicitly chooses to gate on them.
254269

docs/go/operator/import-ingestion.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ Useful flags:
183183
`cleanup-follow-imports` and `audit-follow-imports` only. Optional. Repeats or accepts comma-separated glob patterns that remove checkpoint and retry-artifact candidates from the matched set after includes are considered. Excludes win over includes.
184184
- `--retention-profile stale|daily|reset`
185185
`cleanup-follow-imports` and `audit-follow-imports` only. Optional. Expands to a documented default age threshold instead of making you spell out `--older-than` every time. `stale` means `1h`, `daily` means `24h`, and `reset` means `0s`. An explicit `--older-than` still overrides the profile.
186-
- `--list-examples`
187-
`cleanup-follow-imports` only. Maintainer-oriented. Lists the checked-in cleanup sample fixture names and relative paths.
188-
- `--refresh-examples[=<name[,name...]>]`
189-
`cleanup-follow-imports` only. Maintainer-oriented. Rewrites the checked-in cleanup sample outputs under `internal/app/testdata`. Run it from the repository root, or pass `--cwd <repo-root>` first; omit the value to refresh every fixture or pass one or more names to refresh only a subset.
190186

191187
## Event Schema
192188

@@ -270,18 +266,41 @@ Checked-in sample outputs for common cleanup flows live under [../../../internal
270266

271267
- [cleanup-follow-imports-daily-dry-run.txt](../../../internal/app/testdata/cleanup-follow-imports-daily-dry-run.txt)
272268
- [cleanup-follow-imports-filtered-cleanup.json](../../../internal/app/testdata/cleanup-follow-imports-filtered-cleanup.json)
269+
- [audit-follow-imports-daily-audit.txt](../../../internal/app/testdata/audit-follow-imports-daily-audit.txt)
270+
- [audit-follow-imports-filtered-audit.json](../../../internal/app/testdata/audit-follow-imports-filtered-audit.json)
273271

274-
If a deliberate cleanup-output change makes those fixtures drift, refresh them from the repository root with:
272+
If a deliberate output change makes those fixtures drift, refresh the cleanup fixtures from the repository root through the test-only maintainer helper:
275273

276274
```powershell
277-
codex-mem.exe cleanup-follow-imports --refresh-examples
275+
$env:CODEX_MEM_REFRESH_CLEANUP_EXAMPLES = "all"
276+
go test ./internal/app -run TestRefreshCleanupFollowImportsExampleFixtures
277+
Remove-Item Env:CODEX_MEM_REFRESH_CLEANUP_EXAMPLES
278278
```
279279

280-
If you only need one fixture while iterating on a specific report shape, first list the available names and then refresh just that subset:
280+
Refresh the audit fixtures the same way:
281281

282282
```powershell
283-
codex-mem.exe cleanup-follow-imports --list-examples
284-
codex-mem.exe cleanup-follow-imports --refresh-examples=filtered-cleanup-json
283+
$env:CODEX_MEM_REFRESH_AUDIT_EXAMPLES = "all"
284+
go test ./internal/app -run TestRefreshAuditFollowImportsExampleFixtures
285+
Remove-Item Env:CODEX_MEM_REFRESH_AUDIT_EXAMPLES
286+
```
287+
288+
If you only need one fixture while iterating on a specific report shape, pass a comma-separated fixture-name subset instead of `all`:
289+
290+
```powershell
291+
$env:CODEX_MEM_REFRESH_CLEANUP_EXAMPLES = "filtered-cleanup-json"
292+
go test ./internal/app -run TestRefreshCleanupFollowImportsExampleFixtures
293+
Remove-Item Env:CODEX_MEM_REFRESH_CLEANUP_EXAMPLES
294+
295+
$env:CODEX_MEM_REFRESH_AUDIT_EXAMPLES = "filtered-audit-json"
296+
go test ./internal/app -run TestRefreshAuditFollowImportsExampleFixtures
297+
Remove-Item Env:CODEX_MEM_REFRESH_AUDIT_EXAMPLES
298+
```
299+
300+
The fixture names live in [follow_examples_test.go](../../../internal/app/follow_examples_test.go), and the ordinary read-only guard remains:
301+
302+
```powershell
303+
go test ./internal/app -run "Test(Audit|Cleanup)FollowImportsExampleOutputsStayInSync"
285304
```
286305

287306
## Operational Notes

internal/app/cleanup_examples.go

Lines changed: 0 additions & 258 deletions
This file was deleted.

0 commit comments

Comments
 (0)