Skip to content

feat(v0.6): content facts + file-matches-pattern, and CreateFile fix action - #53

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

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

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

What & why

The two v0.5 engine-depth items you asked for — "1 then 2":

  1. CreateFile fix action (mechanical) — the missing-file half of plasma fix.
  2. Content facts + file-matches-pattern (the one with a real design decision) — content-aware policy conditions.

1 — CreateFile

A required file at a concrete path (not a glob) that's missing is now created with obvious placeholder content, never overwriting an existing file. A required file named by a glob (LICENSE*, README* — no single filename to derive) stays manual. Idempotent.

$ plasma fix . --policy needs-security.toml --apply
  APPLIED: SECURITY.md     # created with a "# TODO" placeholder

2 — Content facts + file-matches-pattern

The design decision I flagged, and how I resolved it so the v0.4 wire contracts stay frozen:

  • FactSet gains an opt-in, additive file_contents map (collect_opts, valid-UTF-8 files ≤ 1 MiB). It's skip_serializing_if empty, so the default plasma facts snapshot is byte-identical to before — verified by test.
  • Content is collected only when needed: plasma check/fix turn it on automatically iff the policy uses file-matches-pattern (Policy::needs_content); plasma facts --with-contents forces it. The evaluator stays pure — it only ever reads the FactSet it's handed.
  • file-matches-pattern's regex is validated at load (InvalidRegex), so evaluation stays total; the condition is false when a file's content wasn't collected (binary/oversized/off) — a defined semantics, documented.
[[rules]]
id = "no-todo-in-main"
modality = "prohibition"
subject = { type = "repo" }
resource = { type = "file", path = "main.rs" }
condition = { type = "file-matches-pattern", path = "main.rs", pattern = "TODO|FIXME" }
action = { type = "present" }

Verification

  • cargo test --workspace — 100 tests (8 new: CreateFile plan+apply, file-matches-pattern match/no-match/no-content, invalid-regex load rejection, content opt-in serialization, oversized-content skip)
  • cargo clippy --workspace --all-targets -- -D warnings and cargo fmt --check clean
  • Live demos: file-matches-pattern flags a TODO in main.rs; CreateFile generates a missing SECURITY.md; default plasma facts still omits file_contents
  • plasma check . self-check: 0 violations, 110 rules satisfied

Notes

  • New dep: regex (MIT/Apache) in plasma-engine.
  • Wire contracts unchanged; docs/interchange-contracts.adoc documents file_contents as opt-in/additive.
  • Remaining roadmap: UpdateField fix action; integration surfaces (git hooks, CI action, .plasma.toml pinning); release facts; modify-rules stays reserved.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JSVSF9HhKUhDrEV4xkMEXq


Generated by Claude Code

…action

Two v0.5-depth increments (1 then 2 from the roadmap).

CreateFile action:
- a required file at a CONCRETE path (not a glob) that is missing is now
  created with obvious placeholder content, never overwriting an existing
  file; glob-named required files (LICENSE*, README*) stay manual since no
  single filename can be derived. Idempotent.

Content facts + file-matches-pattern:
- FactSet gains an opt-in file_contents map (collect_opts, valid-UTF-8
  files <= 1 MiB). It is omitted from serialized output when empty, so the
  default `plasma facts` snapshot is byte-identical to v0.4/v0.5 — the
  frozen wire contract is preserved (additive field only).
- file-matches-pattern is now evaluable: its regex is validated at load
  (InvalidRegex) so evaluation stays total; it is false when a file's
  content was not collected (binary/oversized/contents off).
- plasma check/fix collect content automatically iff the policy uses
  file-matches-pattern (Policy::needs_content); plasma facts --with-contents
  forces it. Purity/determinism preserved: eval still operates only on the
  FactSet it is given.

100 tests (8 new); docs updated (engine-v0-design, interchange-contracts,
cli-design); versions unified at 0.6.0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JSVSF9HhKUhDrEV4xkMEXq
@hyperpolymath
hyperpolymath marked this pull request as ready for review July 17, 2026 06:10
@hyperpolymath
hyperpolymath merged commit dfcfe44 into main Jul 17, 2026
22 checks passed
@hyperpolymath
hyperpolymath deleted the claude/project-scope-discussion-1dvjn8 branch July 17, 2026 06:10
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