Skip to content

refactor: consolidate audit migration test fixtures - #118277

Merged
steipete merged 1 commit into
mainfrom
codex/goal100k-state-migration-wave20-2d45
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/goal100k-state-migration-wave20-2d45

Conversation

@steipete

@steipete steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The audit-log import and crash-recovery suites repeated their temporary state layout, audit event construction, journal bytes, migration invocation, and file-handle fault injection across 1,604 lines. That duplication made the same migration lifecycle harder to review and update consistently.

Why This Change Was Made

This introduces one test-only fixture owned by the legacy audit migration lifecycle and rewrites the two existing suites around it. Distinct checkpoint, generation, downgrade, restore, durability, lock, symlink, and old-writer scenarios remain explicit in their test bodies.

  • Architectural owner: legacy audit import/recovery test lifecycle under src/infra/
  • Canonical fix: one test-only path/event/journal/fault-injection fixture
  • Removed paths: duplicated setup and recovery-journal builders in both suites
  • Production LOC delta: 0
  • SQLite schema/version delta: 0
  • Test delta: +703/-1161, net -458 LOC
  • Behavior inventory: exact 29/29 test titles/order and 156/156 assertion sites preserved

User Impact

No user-visible or production behavior change. Maintainers get a smaller, more coherent audit migration regression surface.

Evidence

  • Local focused Vitest before final lint-only rename: 29/29 tests passed.
  • Exact-head Blacksmith Testbox tbx_01kz29pbcd3ej9g5y73tm2wm8j: pnpm check:changed passed, including formatting, ratchets, dead-export scan, core-test typecheck, and lint.
  • Same exact-head Testbox run: 122/122 focused and sibling tests passed across audit logs, audit recovery, audit backup, SQLite audit record store, and the state migration orchestrator.
  • AST parity against the parent commit: audit logs 19 titles + 114 assertions; audit recovery 10 titles + 42 assertions; exact order and counts unchanged.
  • git diff --check: passed.
  • Exhaustive central collision audit: zero open exact-path overlaps across all three touched paths through 2026-08-02T22:00:54Z.

@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Aug 2, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 7:24 PM ET / 23:24 UTC.

ClawSweeper review

What this changes

The PR replaces duplicated temporary-state, audit-record, recovery-journal, and controlled file-operation setup in two legacy audit-migration Vitest suites with a shared test-only fixture.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This is a coherent, test-only consolidation that keeps the audit migration’s distinct import and recovery scenarios explicit while moving duplicated setup into one private fixture. The checked PR head is not present on current main, and the protected maintainer label means it should remain open for ordinary maintainer review rather than automated cleanup.

Priority: P3
Reviewed head: 464fdc7adccc73aab625a207ef399bb550284f15

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, internally coherent test refactor with source-backed preservation of the migration entry point and fault-injection mechanics.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-labeled PR changes only Vitest fixture code and no runtime behavior; the PR body additionally reports exact-head Testbox migration and SQLite coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-labeled PR changes only Vitest fixture code and no runtime behavior; the PR body additionally reports exact-head Testbox migration and SQLite coverage.
Evidence reviewed 6 items Shared fixture is test-only: The added helper owns temporary state paths, representative audit events, journal construction, and fault injection; it invokes the existing migration functions rather than changing their implementation.
Migration contract remains production-owned: The fixture delegates detection and migration to the existing audit-migration owner, preserving the production entry point exercised by both suites.
Failure injection semantics were retained: The shared helper preserves the file-handle chmod call ordinal and partial-first-write/second-write-failure behavior used by the recovery tests.
Findings None None.
Security None None.

How this fits together

The legacy audit migration reads retired audit JSONL files and recovery journals, imports their records into SQLite-backed audit stores, and preserves crash-recovery ordering. The changed fixture builds those legacy on-disk states and injects filesystem failures so the two suites can exercise the production migration owner consistently.

flowchart LR
  A[Audit migration test cases] --> B[Shared test fixture]
  B --> C[Legacy audit files and journals]
  C --> D[Audit migration owner]
  D --> E[SQLite audit stores]
  E --> F[Recovery assertions]
Loading

Before merge

  • Add real behavior proof - Not applicable: This maintainer-labeled PR changes only Vitest fixture code and no runtime behavior; the PR body additionally reports exact-head Testbox migration and SQLite coverage.
  • Complete next step (P2) - No mechanical repair is indicated; the remaining action is ordinary protected-label maintainer review of an otherwise correct test-only refactor.
Agent review details

Security

None.

PR surface

Source +230, Tests -688. Total -458 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 230 0 +230
Tests 2 473 1161 -688
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 703 1161 -458

Review metrics

None.

Stored data model

Persistent data-model change detected: database schema: src/infra/state-migrations.audit-logs.test.ts, database schema: src/infra/state-migrations.audit-recovery.test.ts, migration/backfill/repair: src/infra/state-migrations.audit-recovery.test.ts, migration/backfill/repair: src/infra/state-migrations.audit.test-support.ts, serialized state: src/infra/state-migrations.audit-logs.test.ts, serialized state: src/infra/state-migrations.audit-recovery.test.ts, and 4 more. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Land the private src/infra test-support fixture after normal maintainer review, keeping it scoped to audit migration tests and leaving production migration, schema, and runtime behavior unchanged.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR refactors regression-test setup rather than fixing a reported user-visible defect. The behavioral path is nonetheless covered by the existing audit import and recovery suites described in the PR evidence.

Is this the best way to solve the issue?

Yes. A private audit-specific fixture is the narrowest maintainable owner boundary: it centralizes repeated setup and failure injection without generalizing unrelated test infrastructure or changing the production migration owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5aae66f4e368.

Labels

Label justifications:

  • P3: The PR is a focused test-maintenance refactor with no production, configuration, schema, or user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-labeled PR changes only Vitest fixture code and no runtime behavior; the PR body additionally reports exact-head Testbox migration and SQLite coverage.

Evidence

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the PR head and the earlier SQLite/journal audit-migration work that established the surrounding migration and recovery architecture. (role: audit migration refactor author and recent area contributor; confidence: high; commits: 464fdc7adccc, 9d97e10efe08; files: src/infra/state-migrations.audit.test-support.ts, src/infra/state-migrations.audit-logs.ts, src/infra/state-migrations.audit-checkpoints.ts)
  • Vincent Koc: Vincent Koc authored the recent checkpoint-fixture adjustment in this audit migration test area, making them a useful adjacent routing contact for fixture semantics. (role: recent checkpoint-fixture contributor; confidence: medium; commits: a6622ddb6fd3; files: src/infra/state-migrations.audit-logs.test.ts, src/infra/state-migrations.audit-recovery.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-02T22:57:00.392Z sha 464fdc7 :: needs real behavior proof before merge. :: none

@steipete
steipete marked this pull request as ready for review August 2, 2026 23:19
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

ClawSweeper before-merge items addressed on exact head 464fdc7adccc73aab625a207ef399bb550284f15:

  • Real behavior proof: not applicable for this test-only fixture extraction. Production, schema, generated-type, and schema-version deltas are all zero. The relevant behavioral proof is the exact-head Blacksmith Testbox run: pnpm check:changed plus 122 focused/sibling migration and SQLite tests, all green (run 30770312839).
  • Ordinary author readiness / maintainer review: the PR is now ready. Two independent xhigh reviews both returned CLEAN / APPROVE with no actionable findings. They directly checked the complete audit migration/recovery owners, Doctor and backup callers, Node/Kysely/fs-safe contracts, history, fault ordinals, journal byte/order semantics, and exact 29-test / 156-assertion parity.

Best-fix judgment from both reviews: the private audit-specific test-support module is the narrowest coherent owner boundary; genericizing it or combining the suites would obscure the distinct import/recovery invariants.

@steipete
steipete merged commit 51548dd into main Aug 3, 2026
160 of 165 checks passed
@steipete
steipete deleted the codex/goal100k-state-migration-wave20-2d45 branch August 3, 2026 00:08
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant