Skip to content

Record hook degradation status#116

Merged
azalio merged 2 commits into
mainfrom
2604.017-3-hook-degradation-status
May 16, 2026
Merged

Record hook degradation status#116
azalio merged 2 commits into
mainfrom
2604.017-3-hook-degradation-status

Conversation

@azalio
Copy link
Copy Markdown
Owner

@azalio azalio commented May 16, 2026

Summary

  • Persist explicit skipped hook reasons for malformed hook input, unsupported tools, and insignificant Bash commands when branch state is safe to update.
  • Preserve the non-blocking/no-clobber hook contract for missing or invalid step state.
  • Move 2604.017-3 from the active improvement plan to done and capture the reusable hook-input testing rule.

Validation

  • pytest tests/test_workflow_context_injector.py tests/test_template_sync.py -v
  • pytest tests/test_map_step_runner.py::test_write_run_health_report_creates_report_and_manifest tests/test_artifact_schemas.py::test_validate_run_health_report_schema -v
  • make lint
  • pytest -m "not slow"
  • Generated-project uv run --no-sync mapify init <temp> --no-git --mcp none hook smokes for insignificant Bash and non-string Bash payloads

Copilot AI review requested due to automatic review settings May 16, 2026 11:04
Copy link
Copy Markdown
Contributor

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

This PR expands workflow hook observability by recording skipped/degraded hook outcomes into branch state when it is safe to do so, so run-health reporting can surface why context injection did not happen.

Changes:

  • Adds safe step-state reading and skipped hook status persistence for malformed/unsupported/insignificant hook paths.
  • Adds regression tests for skipped Bash, malformed hook input, missing state, invalid state preservation, and non-string Bash payloads.
  • Updates README, usage, architecture, roadmap, learned rules, and improvement tracking docs for the new diagnostic signal.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
.claude/hooks/workflow-context-injector.py Adds degradation-aware state reads and skipped hook status writes.
src/mapify_cli/templates/hooks/workflow-context-injector.py Syncs the shipped hook template with the source hook changes.
tests/test_workflow_context_injector.py Adds hook regression coverage for skipped and malformed input paths.
README.md Documents skipped hook reasons in run health reporting.
docs/USAGE.md Updates usage docs for run-health hook degradation signals.
docs/ARCHITECTURE.md Updates architecture description of run-health resiliency signals.
docs/roadmap.md Marks skipped hook reasons as part of shipped runtime alignment.
docs/learned/testing-strategies.md Adds a reusable testing rule for untrusted hook JSON fields.
docs/improvement-plan.md Removes the completed hook degradation coverage plan item.
docs/improvement-loop-log.md Records implementation and validation of the improvement slice.
docs/improvement-done.md Adds the completed improvement entry and validation summary.
Comments suppressed due to low confidence (3)

.claude/hooks/workflow-context-injector.py:389

  • Non-string Bash commands are malformed hook input, but normalizing them to an empty command makes the persisted skip reason become bash command not significant. That hides the malformed-payload degradation this PR is trying to make auditable; preserve a separate malformed-command reason before falling through to significance checks.
        command = tool_input.get("command", "")
        if not isinstance(command, str):
            command = ""

src/mapify_cli/templates/hooks/workflow-context-injector.py:389

  • Non-string Bash commands are malformed hook input, but normalizing them to an empty command makes the persisted skip reason become bash command not significant. That hides the malformed-payload degradation this PR is trying to make auditable; preserve a separate malformed-command reason before falling through to significance checks.
        command = tool_input.get("command", "")
        if not isinstance(command, str):
            command = ""

.claude/hooks/workflow-context-injector.py:398

  • The new unsupported-tool skip path is not covered by the updated hook tests; the added tests exercise malformed JSON and Bash skips, but nothing asserts that an unsupported tool with parseable state persists tool not configured for workflow injection without emitting context. Add a regression so this documented behavior does not silently regress.
    if not should_inject:
        reason = "tool not configured for workflow injection"
        if tool_name == "Bash":
            reason = "bash command not significant"
        elif not tool_name:
            reason = "missing tool_name"
        record_skip_if_state_available(branch, reason, tool_name or "unknown")

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

Comment thread .claude/hooks/workflow-context-injector.py
Comment thread src/mapify_cli/templates/hooks/workflow-context-injector.py
Comment thread tests/test_workflow_context_injector.py Outdated
@azalio azalio merged commit 04434a3 into main May 16, 2026
6 checks passed
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