Skip to content

feat: block-plugin-scaffold - preservation-safe merge (BPS-12 phase 3) - #68

Merged
krugazul merged 1 commit into
feat/bps-12-engine-boundaryfrom
feat/bps-12-safe-output
Nov 6, 2026
Merged

krugazul merged 1 commit into
feat/bps-12-engine-boundaryfrom
feat/bps-12-safe-output

Conversation

@krugazul

@krugazul krugazul commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Feature Pull Request

Phase 3 of 4 for BPS-12. It stacks on #67, which stacks on #66; this PR's diff is only phase 3.

Linked issues

Part of #65

What this adds

scripts/mcp/merge.js writes an approved, current preview into its destination, following the contract's merge rules:

  • Writes only planned paths. It never deletes anything, never writes a Git path and never touches unrelated files. When the destination is new, it creates only that folder.
  • Re-checks each path just before writing it, including every folder above it. An edit or a symbolic link that appears after approval stops the write.
  • Writes each file atomically: to a temporary file beside the target, then renamed into place. Written files get the generated file's permissions.
  • Backs up every file before overwriting it, to logs/mcp-<slug>-<timestamp>-backup/.
  • Records each step in logs/mcp-<slug>-<timestamp>.journal.jsonl.
  • Reports failures with PARTIAL_WRITE, listing where writing stopped, what was and wasn't written, the backup folder and the journal. Previewing and generating again finishes the rest.

docs/MCP-PLUGIN-GENERATION.md now documents backups, the journal, recovery and file modes.

Verification

All checks were done by generating plugins; the scaffold's own test suite was not run. 34 scripted checks pass:

  • New folder: the output is byte-identical to a direct generator run with the same clock, including executable bits and links.
  • Second run into the same folder: everything is unchanged, nothing is written, and file modification times stay the same.
  • Existing Git repository: .git, a nested sub/.git, .gitmodules and unrelated files keep the same content, mode and modification time. Overwritten files are backed up with their old content. git status shows no deletions and no temporary files are left behind.
  • Symbolic links: a link in a planned path or at a planned file blocks generation with CONFLICT. Nothing is written in the destination or through the link.
  • Read-only folder: writing stops with PARTIAL_WRITE (405 written, 159 not), with backups and a journal. After fixing the permission, previewing and generating again completes the plugin exactly.
  • Simulated crash after 39 files: every file is either its old or its new version.
  • File edited during generation: it is not overwritten.
  • Destination created after the preview: generation stops with STALE_PREVIEW.

The merged plugin's own npm ci, build, lint:js, test:unit and composer test also pass.

Changelog

Added

  • Safe merge for local MCP generation (BPS-12, scripts/mcp/merge.js).

Checklist (Global DoD / PR)

  • All AC met and demonstrated (for this phase: T4)
  • Tests added/updated: verified by generating plugins instead, as agreed
  • Accessibility checklist: not applicable, no user interface
  • Docs/readme/changelog updated
  • Security checklist: no deletes, no writes through links, re-checked before each write, approval bound by hash
  • Code/design reviews approved
  • CI green

🤖 Generated with Claude Code

Phase 3 of BPS-12 (T4).

scripts/mcp/merge.js applies an approved, current preview:
- writes only planned create and overwrite paths, folders first;
- never deletes, never writes Git paths or unrelated files, and creates
  only the destination folder itself when it is new;
- re-checks each path, and every folder above it, just before writing,
  so edits or links that appear after approval stop the write;
- writes each file to a temporary name beside it and renames it into
  place, keeping the generated file's permissions;
- backs up every file before overwriting it, and records each step in a
  JSON Lines journal next to the preview's log;
- on failure returns PARTIAL_WRITE with where it stopped, what was and
  was not written, the backup folder and the journal; previewing and
  generating again completes the rest.

The contract documents backups, the journal, recovery and file modes.

Verified by generating plugins only: 34 scripted checks (exact match
with the generator for a new folder, no-op regeneration, a real Git
repository with nested .git and unrelated files, links, a read-only
folder, a simulated crash, a file edited mid-write), and the merged
plugin's own npm ci, build, lint:js, test:unit and composer test pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Nov 6, 2026

Copy link
Copy Markdown

BPS-12

@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML; Path: .coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: d6f79a07-a0cc-4bc3-ba0d-ddc7a9014bd0
Commits

Reviewing files that changed from the base of the PR and between 7bc1d74 and 0371ddb.

Files selected for processing: 4

  • CHANGELOG.md
  • docs/MCP-PLUGIN-GENERATION.md
  • scripts/mcp/merge.js
  • scripts/mcp/preview.js
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@krugazul
krugazul marked this pull request as ready for review November 6, 2026 09:36
@krugazul
krugazul added this pull request to stack #71 November 6, 2026 10:18
@krugazul
krugazul merged commit 6a4eb30 into develop Nov 6, 2026
6 of 20 checks passed
@krugazul
krugazul deleted the feat/bps-12-safe-output branch November 6, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant