Skip to content

[Change] Safe project artifact writes for init and IDE setup #490

@djm81

Description

@djm81

Why

specfact init and specfact init ide currently mutate user-owned project artifacts such as .vscode/settings.json without a first-class safety contract. Issue #487 showed that a setup run can wipe unrelated local configuration, forcing manual restore and repair. That is unacceptable for any tool writing into customer repositories.

What Changes

  • introduce a core safe-write policy for project artifacts with declared ownership and mutation modes (create_only, merge_structured, append_managed_block, explicit_replace)
  • route init/setup file mutations through a shared helper instead of ad hoc overwrite logic
  • preserve unrelated user configuration in partial-ownership files such as .vscode/settings.json
  • require backup/recovery metadata for lossy replacement paths
  • add CI/static coverage that flags unsafe raw writes to protected user-project artifacts
  • add regression fixtures proving existing user config survives init/setup flows
  • coordinate paired runtime adoption in specfact-cli-modules

Acceptance Criteria

  • .vscode/settings.json merges only SpecFact-managed entries and preserves unrelated settings
  • malformed structured config does not get silently replaced by default
  • destructive replacement creates a recoverable backup and explicit output
  • CI fails if protected init/setup paths bypass the sanctioned safe-write helper
  • paired modules-side adoption change is tracked and linked

Dependencies

Related Issues/PRs

Additional Context

This is intended as a prevention-by-design change, not a point fix for a single symptom.


OpenSpec Change Proposal: profile-04-safe-project-artifact-writes

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions