Skip to content

feat(v0.3): action planner — plasma fix (plan/apply, backups) - #48

Merged
hyperpolymath merged 1 commit into
mainfrom
claude/project-scope-discussion-1dvjn8
Jul 9, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
claude/project-scope-discussion-1dvjn8

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

What & why

First v0.3 roadmap item: a policy-driven remediation surface. plasma check tells you what's wrong; plasma fix proposes and applies the corrections. This establishes the Action/Plan/apply architecture that later increments extend.

Design

Same purity split as the evaluator:

  • plan(policy, evaluation, ctx) -> Plan is pure (plasma-engine/src/action.rs). Each violation becomes either a mechanical Action or a ManualItem with a reason — nothing is silently unfixable. FixContext injects license/author/year (never clock-derived), so planning stays deterministic.
  • apply(plan, root, opts) -> ApplyOutcome is the IO boundary (plasma-engine/src/apply.rs, the counterpart to facts.rs). It writes <file>.bak backups first (unless --no-backup) and is idempotent — a file that already has a header is skipped, not double-written.

Action vocabulary (v0.3): AddSpdxHeader (the one auto-action). Missing required files (LICENSE/README), unparsable headers, and prohibitions route to manual. The Action enum and Plan shape are the stable contract; CreateFile/UpdateField come later.

Relationship to plasma audit --fix: that's the license-specific header tool; plasma fix is the general policy-remediation surface driven by engine findings — headers are just its first action class.

CLI

plasma fix [PATH] [--policy F] [--license L] [--author A] [--apply] [--no-backup] [--format human|json]

Dry-run by default (prints the plan; exit 1 when actions are pending, so CI can gate on a clean tree). --apply makes the changes (exit 0 unless an action errored).

$ plasma fix .            # on this repo
Nothing to fix.

Tests & verification

  • plasma-engine: 7 new unit tests (planner mapping + apply/backup/idempotency/error). 77 tests total, all green.
  • tests/fix_selftest.rs: 4 CLI integration tests (dry-run no-write, apply+backup, idempotent re-run, json plan).
  • cargo fmt --all -- --check and cargo clippy --workspace --all-targets -- -D warnings clean.
  • plasma check . still passes (0 violations); plasma fix . reports "Nothing to fix."
cargo test --workspace
cargo clippy --workspace --all-targets -- -D warnings
cargo fmt --all -- --check
cargo run -- fix .                 # dry-run

Docs

docs/engine-v0-design.adoc gains an "Action planner" section (plan pure / apply IO, action vocabulary); docs/cli-design.adoc documents plasma fix; ROADMAP.adoc checks off delivered items; CHANGELOG.md [Unreleased]; Justfile gains a fix recipe.

Out of scope (later v0.3 increments)

CreateFile/UpdateField actions, overlay modify-rules/override-rules semantics, content facts + file-matches-pattern.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JSVSF9HhKUhDrEV4xkMEXq


Generated by Claude Code

Adds the first v0.3 roadmap item: a policy-driven remediation surface.

- plasma-engine: pure plan(policy, evaluation, ctx) -> Plan maps each
  violation to a mechanical Action or a ManualItem with a reason (nothing
  silently unfixable). IO boundary apply(plan, root, opts) executes actions,
  writes <file>.bak backups (unless --no-backup), and is idempotent.
- First auto-action AddSpdxHeader; missing files / unparsable headers /
  prohibitions route to manual. Action enum and Plan shape are the stable
  contract for future action types.
- CLI: plasma fix [PATH] [--policy F] [--license L] [--author A] [--apply]
  [--no-backup] [--format human|json]. Dry-run by default (exit 1 when work
  pending), --apply makes changes (exit 0 unless an action errored).
- Docs: engine-v0-design action-planner section; cli-design; ROADMAP;
  CHANGELOG; STATE. Justfile gains a `fix` recipe.
- Tests: 7 engine unit tests + 4 CLI integration tests (77 total, green).

Purity split preserved: plan is pure/total; apply is the sole new IO
boundary alongside facts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JSVSF9HhKUhDrEV4xkMEXq
@hyperpolymath
hyperpolymath marked this pull request as ready for review July 9, 2026 23:38
@hyperpolymath
hyperpolymath merged commit 6d5b2f7 into main Jul 9, 2026
22 checks passed
@hyperpolymath
hyperpolymath deleted the claude/project-scope-discussion-1dvjn8 branch July 9, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants