Repository navigation
feat(v0.3): action planner — plasma fix (plan/apply, backups) - #48
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
First v0.3 roadmap item: a policy-driven remediation surface.
plasma checktells you what's wrong;plasma fixproposes and applies the corrections. This establishes theAction/Plan/applyarchitecture that later increments extend.Design
Same purity split as the evaluator:
plan(policy, evaluation, ctx) -> Planis pure (plasma-engine/src/action.rs). Each violation becomes either a mechanicalActionor aManualItemwith a reason — nothing is silently unfixable.FixContextinjectslicense/author/year(never clock-derived), so planning stays deterministic.apply(plan, root, opts) -> ApplyOutcomeis the IO boundary (plasma-engine/src/apply.rs, the counterpart tofacts.rs). It writes<file>.bakbackups 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. TheActionenum andPlanshape are the stable contract;CreateFile/UpdateFieldcome later.Relationship to
plasma audit --fix: that's the license-specific header tool;plasma fixis the general policy-remediation surface driven by engine findings — headers are just its first action class.CLI
Dry-run by default (prints the plan; exit 1 when actions are pending, so CI can gate on a clean tree).
--applymakes the changes (exit 0 unless an action errored).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 -- --checkandcargo clippy --workspace --all-targets -- -D warningsclean.plasma check .still passes (0 violations);plasma fix .reports "Nothing to fix."Docs
docs/engine-v0-design.adocgains an "Action planner" section (plan pure / apply IO, action vocabulary);docs/cli-design.adocdocumentsplasma fix;ROADMAP.adocchecks off delivered items;CHANGELOG.md[Unreleased];Justfilegains afixrecipe.Out of scope (later v0.3 increments)
CreateFile/UpdateFieldactions, overlaymodify-rules/override-rulessemantics, content facts +file-matches-pattern.🤖 Generated with Claude Code
https://claude.ai/code/session_01JSVSF9HhKUhDrEV4xkMEXq
Generated by Claude Code