Skip to content

Backport audit-machinery fixes from MediaIngredientMech PR #32#32

Merged
realmarcin merged 3 commits into
mainfrom
backport/audit-machinery-fixes
May 25, 2026
Merged

Backport audit-machinery fixes from MediaIngredientMech PR #32#32
realmarcin merged 3 commits into
mainfrom
backport/audit-machinery-fixes

Conversation

@realmarcin
Copy link
Copy Markdown
Contributor

Summary

Three small but real bugs surfaced by Copilot on the recent MIM port of the audit machinery. All apply equally to CultureMech (this repo is the source of the same code), so backporting now keeps the four-repo family in sync.

File Fix Impact
`scripts/validate_strict.py` `SCHEMA_PATH` / `OAK_CONFIG_PATH` / `DEFAULT_ROOTS` resolved relative to `file` A non-repo-root invocation previously failed silently (no schema found → 0 files / 0 errors → exit 0). Now works from any cwd.
`src/culturemech/validation/write_validated.py` Add `default_flow_style=False` + `encoding="utf-8"` to default yaml.safe_dump opts Roundtripping a recipe through `write_validated_recipe` no longer churns block / flow style. Matches the convention used by every other yaml writer in this repo.
`scripts/audit_writers.py` Drop unused `ROOT` global Ruff F841 hygiene.

No semantic change to the validation policy or the audit categories.

Test plan

  • All three files `ast.parse` cleanly.
  • `uv run python scripts/validate_strict.py --sample 5` → 0 errors as before.
  • cwd-independence: invoking with absolute path from `/tmp` now finds the schema and validates 3 files cleanly (previous behavior was a silent exit 2 / no files found).

🤖 Generated with Claude Code

Three small but real bugs surfaced by Copilot on the MIM port that all
apply equally to CultureMech (this repo is the source of the same code).

- scripts/validate_strict.py: SCHEMA_PATH / OAK_CONFIG_PATH / DEFAULT_ROOTS
  are now resolved relative to __file__ so the harness works regardless
  of the caller's cwd (previously a non-repo-root invocation silently
  failed to locate the schema and exited cleanly with no errors found).
- src/culturemech/validation/write_validated.py: add
  default_flow_style=False and encoding="utf-8" to the default yaml.safe_dump
  options so re-running write_validated_recipe over an existing file
  produces byte-identical output instead of churning block / flow style
  (matches the convention used by every other yaml writer in the repo).
- scripts/audit_writers.py: drop unused ROOT global (F841).

No semantic change to the validation policy or the audit categories.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 25, 2026 04:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Backports a small set of audit/validation harness fixes from the MediaIngredientMech “audit machinery” work to keep the shared multi-repo code in sync and reduce YAML churn / cwd-dependence in tooling.

Changes:

  • Make scripts/validate_strict.py resolve schema/config paths relative to the repository root for cwd-independent execution.
  • Adjust write_validated_recipe YAML emission defaults (block style, explicit UTF-8 output) to reduce formatting diffs.
  • Remove an unused global in scripts/audit_writers.py (ruff F841 hygiene).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/culturemech/validation/write_validated.py Tweaks YAML dumping defaults and file encoding for stable recipe round-trips.
scripts/validate_strict.py Resolves schema/config/default roots relative to __file__ so validation works from any cwd.
scripts/audit_writers.py Removes an unused ROOT global.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/culturemech/validation/write_validated.py
realmarcin and others added 2 commits May 24, 2026 21:51
…ed.py

Copilot caught a sibling instance of the same cwd-relative bug — the
DEFAULT_SCHEMA_PATH in write_validated.py was still a literal
Path("src/culturemech/schema/...") and would silently fail to find the
schema when write_validated_recipe() was called from a non-repo-root cwd.
Resolve it relative to __file__ to match validate_strict.py.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@realmarcin realmarcin merged commit ee3d927 into main May 25, 2026
1 check passed
@realmarcin realmarcin deleted the backport/audit-machinery-fixes branch May 25, 2026 04:52
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