Skip to content

feat(436): wire validate-wardley-math hook + add owm fence alias#477

Merged
tractorjuice merged 1 commit into
mainfrom
feat/436-wire-wardley-validator
May 15, 2026
Merged

feat(436): wire validate-wardley-math hook + add owm fence alias#477
tractorjuice merged 1 commit into
mainfrom
feat/436-wire-wardley-validator

Conversation

@tractorjuice
Copy link
Copy Markdown
Owner

Summary

Closes step 1 of the owner-suggested scope on #436 — the existing validate-wardley-math.mjs hook (271 lines, four checks) was sitting in arckit-claude/hooks/ unregistered. This PR wires it up so Wardley artefacts are validated before the Write tool puts a broken map on disk.

  • Refactor hook from Stop-mode disk scan to PreToolUse:Write reading tool_input.{file_path, content}. Removes the 5-minute mtime window and stop_hook_active loop-guard — neither apply on PreToolUse.
  • Register in hooks.json under PreToolUse:Write with if: \"Write(/projects/**/wardley-maps/**)\", matching the existing validate-arc-filename / score-validator pattern.
  • Recognise the owm fence alias alongside wardley. The wardley-mapping skill examples use ```owm; templates use ```wardley. Both now lint.
  • Enforce the unit-square [0, 1] coordinate range on component lines inside the OWM block too — previously only Component Inventory table rows were range-checked.
  • hooks/README.md: spell out the hook's event/scope and what it checks.

Blocks via {decision: \"block\", reason} so the model sees the validation report and self-corrects, instead of hitting a hard permission error the user has to read.

Out of scope (follow-ups on #436)

  • Dangling references in link / evolve / pipeline, annotation-index reuse, pipeline visibility, and style-name typos — these need a real parser (wardley-script-parser). Captured in the issue.
  • Mermaid block validator — sibling issue Add Mermaid syntax validation for generated diagrams (linter / pre-commit hook) #435. The Mermaid wardley-beta bare-digit check already in this hook is the only Mermaid coverage; that's incidental because it's inside the same artefact.

Test plan

  • Smoke test 1: dirty input with stage mismatch + out-of-range OWM coord + OWM/inventory mismatch + Mermaid bare-digit token → blocks with all four error classes in the reason field
  • Smoke test 2: clean OWM block with matching inventory → empty output (allows write)
  • Smoke test 3: Write to a non-wardley path → early exit, empty output
  • markdownlint-cli2 on touched README → 0 errors
  • Integration test against a /arckit:wardley run in a test repo (recommend arckit-test-project-v48-arckit-as-a-service per the issue) — block path should surface the reason and let the model self-correct on retry

🤖 Generated with Claude Code

Closes #436 step 1 of the owner's suggested scope: wire the existing
(but unregistered) `validate-wardley-math.mjs` so Wardley artefacts are
checked before they hit disk.

Changes:
- Refactor hook from Stop-mode (disk mtime scan) to PreToolUse:Write
  reading `tool_input.{file_path,content}`. Removes the 5-minute mtime
  window and stop_hook_active loop-guard since neither apply now.
- Register under PreToolUse:Write with
  `if: "Write(/projects/**/wardley-maps/**)"`, matching the
  validate-arc-filename and score-validator pattern.
- Recognise `owm` fence alias alongside `wardley` (the wardley-mapping
  skill examples use the OWM alias; templates use the wardley alias).
- Enforce the OWM unit-square coordinate range on `component` lines
  inside the OWM block, not only on Component Inventory table rows.
- README: clarify the hook entry with its event/scope and what it checks.

Out of scope (follow-up on #436):
- Dangling references, annotation index reuse, pipeline visibility, and
  style-name typos need a real parser (`wardley-script-parser`) — not
  this PR.
- Mermaid block validator is the sibling issue #435.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant