Skip to content

fix(models): prepare catalog pairs before replacing outputs - #160157

Merged
steipete merged 4 commits into
mainfrom
fix/r97-forward-12
Sep 28, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/r97-forward-12

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

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 45f97d88dd85fdf302acfa1fdef2193ff53bf406 onto 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-lane is intentionally omitted because the required recovery documentation changes docs/plugins/manifest/models.md, outside scripts/ and test/scripts/.

Evidence

Review correction (e47ed27418b82)

  • Regression before the cleanup fix: 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.
  • Green after: 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.
  • Sibling proof: node scripts/run-vitest.mjs run --maxWorkers=1 test/scripts/publish-model-catalog.test.ts — 60 passed. Total focused proof: 79 tests.
  • Script and root-test TypeScript lanes, targeted lint and formatting, docs MDX validation, and git diff --check — passed. Changed-check dry-run inspected; full pnpm check:changed intentionally skipped for this bounded review correction. CI test duration for this correction is not yet available.
  • Independent Codex autoreview: local correction review and complete committed branch review (--mode branch --base 2d39f2f738a89c27e0852943486af5c3971c4098 --engine codex --max-priority P1) — both scoped-clean, no accepted/actionable P0/P1 findings. Branch review covers e47ed27418b82; unchanged dependency behavior was inspected separately and supplied as context.
  • No stored data schema, catalog format, migration, dependency, or runtime update change. This correction only changes deletion eligibility for temporary recovery artifacts; documented manual recovery remains unchanged.

Original implementation (ce14401ff873)

  • Red before production changes: 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 preserving previous v1; an injected second-write ENOSPC left v2 as partial instead of previous v2.
  • Green after: 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.
  • Test cost: 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.
  • Independent branch review: .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>' with TMPDIR=$(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:changed initially 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:changed passed 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)

  • Symlinked outputs keep working (ClawSweeper P1, adopting its recommendation): an existing symlink passed as --out or --out-v2 is 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 previous writeFileSync. Two paths that resolve to the same target are rejected. Symlink cycles fail with a clear error. The v1-only writer is unchanged.
  • Exact identities (ClawSweeper P2/security): recovery directory/file identities and output snapshots use BigInt dev/ino (lstatSync/fstatSync with bigint: true), so values above 2^53 cannot alias before unlinkSync; zero identities are still never trusted for deletion.
  • Real publisher proof (node --import tsx scripts/publish-model-catalog.mts --out <tmp>/links/v1.json --out-v2 <tmp>/links/v2.json, v1 link through parent/../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 matching generatedAt/sourceCommit, no recovery directories left.
  • Tests: eight new regressions failed on the previous head and pass now; 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 --check pass. Autoreview (branch mode, P1): scoped-clean.
  • Merged current main first (no conflicts). Production helper grew by 29 lines for symlink resolution and exact snapshots.

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]>
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: M labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 28, 2026, 7:17 AM ET / 11:17 UTC (Revision 3).

ClawSweeper review

What this changes

The 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
Reviewed head: 7c2e40274175b76b47a3afc57453b5a6b115c4bb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused repair has useful real-path and fault evidence, and the earlier concrete findings are addressed on the current head.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR reports an after-fix run of the changed publisher CLI with existing and dangling symlink outputs, observing both links preserved and matching catalog metadata. Its production-entrypoint tests use real isolated files with injected preparation, rename, and identity faults and observe retained recovery or skipped deletion. The catalog JSON format and stored-data contract do not change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports an after-fix run of the changed publisher CLI with existing and dangling symlink outputs, observing both links preserved and matching catalog metadata. Its production-entrypoint tests use real isolated files with injected preparation, rename, and identity faults and observe retained recovery or skipped deletion. The catalog JSON format and stored-data contract do not change.
Evidence reviewed 7 items Current main still has the reported failure path: The fetched main revision writes v1 before preparing the v2 destination, so a later v2 failure can leave mismatched outputs.
Paired publication and recovery: The introduced helper prepares both recovery sets before replacing either output and retains them after uncertain publication.
Earlier findings addressed: The current helper resolves output symlinks before publication and uses BigInt device and inode values for recovery cleanup; the added tests exercise both behaviors through the publisher.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Tests +375, Docs +23, Other +220. Total +618 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 375 0 +375
Docs 1 23 0 +23
Config 0 0 0 0
Generated 0 0 0 0
Other 2 225 5 +220
Total 4 623 5 +618

Review metrics

Metric Value Why it matters
Implementation and test growth production net +220 lines; tests +375 lines The production growth implements staged publication and recovery, while the tests cover its filesystem failure cases.

Stored data model

Persistent data-model change detected: serialized state: scripts/publish-model-catalog.mts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded reliability fix for maintainer catalog tooling, with limited direct runtime impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports an after-fix run of the changed publisher CLI with existing and dangling symlink outputs, observing both links preserved and matching catalog metadata. Its production-entrypoint tests use real isolated files with injected preparation, rename, and identity faults and observe retained recovery or skipped deletion. The catalog JSON format and stored-data contract do not change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports an after-fix run of the changed publisher CLI with existing and dangling symlink outputs, observing both links preserved and matching catalog metadata. Its production-entrypoint tests use real isolated files with injected preparation, rename, and identity faults and observe retained recovery or skipped deletion. The catalog JSON format and stored-data contract do not change.

Evidence

What I checked:

  • Current main still has the reported failure path: The fetched main revision writes v1 before preparing the v2 destination, so a later v2 failure can leave mismatched outputs. (scripts/publish-model-catalog.mts:1198, f9c8af76343e)
  • Paired publication and recovery: The introduced helper prepares both recovery sets before replacing either output and retains them after uncertain publication. (scripts/lib/publish-model-catalog-files.mts:125, 7c2e40274175)
  • Earlier findings addressed: The current helper resolves output symlinks before publication and uses BigInt device and inode values for recovery cleanup; the added tests exercise both behaviors through the publisher. (scripts/lib/publish-model-catalog-files.mts:77, 7c2e40274175)
  • Final cleanup boundary coverage: The new fault cases retain substituted recovery entries; the large-identity cases also assert that unlink is never called. (test/scripts/publish-model-catalog-v2.test.ts:420, 7c2e40274175)
  • Filesystem dependency contract: The target imports the pinned fs-safe advanced API. Its published 0.21.1 helper checks the sibling temp and performs the final rename after resolving the requested destination; package metadata identifies openclaw/fs-safe as its source repository. (dist/sibling-staged-file.js:217)
  • Reported real publisher proof: The PR body reports a CLI run against existing and dangling symlink outputs with both links intact, matching v1/v2 source metadata, and no recovery directories. It also reports before/after fault runs through the actual publisher. These are contributor-reported results, not commands rerun in this read-only review.

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (2 earlier review cycles)
  • reviewed 2026-09-28T05:35:18.785Z sha ce14401 :: blocked before merge. :: [P2] Fail closed before deleting recovery entries with unknown identity
  • reviewed 2026-09-28T06:27:44.228Z sha e47ed27 :: needs real behavior proof before merge. :: [P2] Reject rounded identities before deleting recovery entries | [P1] Preserve the existing symlink output contract

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Status: the first ClawSweeper P1 (unknown/zero file identity before cleanup) is fixed in e47ed27. The new P1s (symlinked --out/--out-v2 paths no longer followed; distinct >2^53 device/inode values could compare equal) are left for the tooling owner; this publisher has no in-repo caller and runs outside CI.

…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.
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@steipete
steipete merged commit d36da73 into main Sep 28, 2026
170 of 172 checks passed
@steipete
steipete deleted the fix/r97-forward-12 branch September 28, 2026 11:46
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L 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