Record hook degradation status#116
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 injectionwithout 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.
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.
Summary
2604.017-3from 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 -vpytest 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 -vmake lintpytest -m "not slow"uv run --no-sync mapify init <temp> --no-git --mcp nonehook smokes for insignificant Bash and non-string Bash payloads