Repository navigation
fix(models): prepare catalog pairs before replacing outputs - #160157
Conversation
Forward-port the paired-output correction from 45f97d8. Preserve recoverable old and new artifacts after partial publication without overwriting foreign replacements. Co-authored-by: Vincent Koc <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 28, 2026, 7:17 AM ET / 11:17 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch prepares both local model catalog files and recovery copies before replacement, preserves output symlinks, and checks exact identities before recovery cleanup. Merge readiness⛔ Blocked before merge - 1 item remains Keep open. Current main still writes the two catalog files sequentially, and the current PR head addresses the symlink and cleanup identity defects raised in the earlier review. Read-only inspection found no remaining blocking defect. Priority: P2 Review scores
Verification
How this fits togetherThe model catalog publisher reads plugin manifests and pricing feeds, then writes versioned JSON catalogs for downstream clients. This PR changes the final filesystem publication step. flowchart LR
A[Plugin manifests] --> C[Build catalogs]
B[Pricing feeds] --> C
C --> D[Prepare both files]
D --> E[Replace output files]
E --> F[Versioned catalogs]
E --> G[Recovery copies]
Before merge
Agent review detailsSecurityNone. PR surfaceTests +375, Docs +23, Other +220. Total +618 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep paired publication in the existing publisher, with recovery artifacts retained whenever replacement is incomplete and clear warnings for cleanup failures. Do we have a high-confidence way to reproduce the issue? Yes. Current main writes v1 before it prepares v2, so a failure preparing or writing v2 can leave the pair inconsistent; the PR reports pre-fix failing publisher cases. I did not execute code in the read-only checkout. Is this the best way to solve the issue? Yes. Preparing both outputs within the existing publisher and retaining recovery on uncertain publication is a focused repair for this local tooling path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f9c8af76343e. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
|
Status: the first ClawSweeper P1 (unknown/zero file identity before cleanup) is fixed in e47ed27. The new P1s (symlinked |
…ties Resolve paired output symlinks to their final targets before preparation, preserving links and creating dangling leaf targets when their parents exist. Reject aliases to the same target. Keep the v1-only writer unchanged. Use BigInt identities for recovery cleanup and output snapshots; retain unknown or changed recovery entries. Consolidate cleanup without changing interrupted-publication retention. Validation: 27 focused publisher tests pass with --maxWorkers=1 (8.15s wall); scripts and test-scripts typechecks, targeted lint, formatting, and diff checks pass. Real publisher CLI proof preserves symlinked outputs, including symlink/.. traversal and a dangling target. Codex autoreview found no actionable P0-P2 findings.
|
Merged via squash.
|
…#160157) * fix(models): prepare catalog pairs before replacing outputs Forward-port the paired-output correction from 45f97d8. Preserve recoverable old and new artifacts after partial publication without overwriting foreign replacements. Co-authored-by: Vincent Koc <[email protected]> * fix(models): reject unknown recovery cleanup identities * fix(models): keep symlinked catalog outputs and exact recovery identities Resolve paired output symlinks to their final targets before preparation, preserving links and creating dangling leaf targets when their parents exist. Reject aliases to the same target. Keep the v1-only writer unchanged. Use BigInt identities for recovery cleanup and output snapshots; retain unknown or changed recovery entries. Consolidate cleanup without changing interrupted-publication retention. Validation: 27 focused publisher tests pass with --maxWorkers=1 (8.15s wall); scripts and test-scripts typechecks, targeted lint, formatting, and diff checks pass. Real publisher CLI proof preserves symlinked outputs, including symlink/.. traversal and a dangling target. Codex autoreview found no actionable P0-P2 findings. --------- Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Fixes mismatched or truncated local model catalog pairs when the v2 destination cannot be prepared or publication fails after v1 has been replaced.
Summary
Forward-ports the paired-output correction from
45f97d88dd85fdf302acfa1fdef2193ff53bf406onto current main, preserving Vincent Koc's contribution. The publisher prepares both candidates and previous-file backups before replacing either destination, rechecks destinations, and publishes each file through the existing filesystem helper's temp-and-rename path. Partial or uncertain publication retains both recovery sets without rolling back over foreign replacements; cleanup failures after success produce warnings. Recovery cleanup requires nonzero, matching device and inode values for directories and files; unknown or changed identities retain the entry and warn.This is maintainer tooling only. The v1-only writer and main's current catalog/pricing behavior stay unchanged. The recovery documentation explicitly requires one publisher and explains that this is neither a multi-file atomic transaction nor a power-loss durability guarantee. No changelog or runtime changes.
release-fast-laneis intentionally omitted because the required recovery documentation changesdocs/plugins/manifest/models.md, outsidescripts/andtest/scripts/.Evidence
Review correction (
e47ed27418b82)node scripts/run-vitest.mjs run --maxWorkers=1 test/scripts/publish-model-catalog-v2.test.ts -t 'retains a substituted'— 4 failed, 2 passed. Substituted recovery directories and files were deleted when the injected path stat returned zero device or inode with Windows comparison semantics; changed nonzero identities were already retained.node scripts/run-vitest.mjs run --maxWorkers=1 test/scripts/publish-model-catalog-v2.test.ts— 19 passed, 15.46 s command wall time (/usr/bin/time -p), 11.63 s Vitest duration, 8.68 s test time. The six table cases use the actual publisher, real isolated replacements, and injected stat results; they verify retained foreign bytes, both published outputs, successful return, and a cleanup warning. No real Windows host, sleeps, or production test seam.node scripts/run-vitest.mjs run --maxWorkers=1 test/scripts/publish-model-catalog.test.ts— 60 passed. Total focused proof: 79 tests.git diff --check— passed. Changed-check dry-run inspected; fullpnpm check:changedintentionally skipped for this bounded review correction. CI test duration for this correction is not yet available.--mode branch --base 2d39f2f738a89c27e0852943486af5c3971c4098 --engine codex --max-priority P1) — both scoped-clean, no accepted/actionable P0/P1 findings. Branch review coverse47ed27418b82; unchanged dependency behavior was inspected separately and supplied as context.Original implementation (
ce14401ff873)node scripts/run-vitest.mjs run --maxWorkers=2 test/scripts/publish-model-catalog-v2.test.ts— 8 failed, 5 passed. A real second-parent failure replaced v1 instead of preservingprevious v1; an injected second-write ENOSPC left v2 aspartialinstead ofprevious v2.node scripts/run-vitest.mjs run --maxWorkers=2 test/scripts/publish-model-catalog-v2.test.ts test/scripts/publish-model-catalog.test.ts— 73 passed across 2 files. Covers preparation and publication failures, existing/absent outputs, retained recovery, observed foreign replacements, cleanup warnings, and unchanged v1-only output.pnpm test test/scripts/publish-model-catalog-v2.test.ts --maxWorkers=1— 13 passed; 27.36 s measured command wall time on a loaded host (18.68 s Vitest duration). Tests exercise the actual publisher with real isolated files and injected filesystem failures; no sleeps or new production test seams. CI duration is not yet available.node scripts/check-docs-mdx.mjs docs/plugins/manifest/models.md— passed, 1 file.git diff --check— passed..agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --engine codex --thinking high --codex-speed fast --max-priority P1 --prompt '<paired-publication scope and evidence>'withTMPDIR=$(getconf DARWIN_USER_TEMP_DIR)— scoped-clean, no actionable P0/P1 findings. Review covered the supplied diff and evidence; unchanged dependencies were inspected separately during implementation.pnpm check:changedinitially failed because the shared pnpm dlx cache referenced a missing Knip executable (MODULE_NOT_FOUND). After hydrating the same pinned Knip 6.32.2 in a task-owned cache,XDG_CACHE_HOME=/private/tmp/r97-12-pnpm-cache pnpm check:changedpassed with exit 0, with no skipped gates. All three unused-export scans reported 0 entries; script/root-test typechecks and final lint checks passed.Review follow-up (head 7c2e402)
--outor--out-v2is resolved to its final target before preparation; publication replaces the target through a sibling temp file in the target's real directory and leaves the link itself unchanged. A dangling link creates its target when the target's parent exists, like the previouswriteFileSync. Two paths that resolve to the same target are rejected. Symlink cycles fail with a clear error. The v1-only writer is unchanged.dev/ino(lstatSync/fstatSyncwithbigint: true), so values above 2^53 cannot alias beforeunlinkSync; zero identities are still never trusted for deletion.node --import tsx scripts/publish-model-catalog.mts --out <tmp>/links/v1.json --out-v2 <tmp>/links/v2.json, v1 link throughparent/../v1.json, v2 link to an absent target): exit 0 in 0.95 s; existing v1 target replaced through the link, dangling v2 target created, both links unchanged, schema versions 1/2 with matchinggeneratedAt/sourceCommit, no recovery directories left.node scripts/run-vitest.mjs run test/scripts/publish-model-catalog-v2.test.ts --maxWorkers=1: 27 passed, 8.15 s wall. Scripts and test-scripts typechecks, targeted lint, oxfmt,git diff --checkpass. Autoreview (branch mode, P1): scoped-clean.