Skip to content

fix(events): preserve unowned Vibe hooks files - #4646

Merged
mnriem merged 6 commits into
github:mainfrom
WOLIKIMCHENG:fix/vibe-hooks-preserve
Oct 21, 2026
Merged

mnriem merged 6 commits into
github:mainfrom
WOLIKIMCHENG:fix/vibe-hooks-preserve

Conversation

@WOLIKIMCHENG

Copy link
Copy Markdown
Contributor

Description

Preserve existing .vibe/hooks.toml files when Vibe cleanup finds no
Spec Kit-managed hooks to remove.

This prevents no-op installation and teardown paths from rewriting user
content, changing line endings, or deleting comment-only and whitespace-only
files. Cleanup of Spec Kit-managed hooks remains unchanged.

Testing

  • Focused Vibe cleanup tests: 22 passed
  • Compile and import checks: passed
  • git diff --check: passed

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (fill in the disclosure below)

AI disclosure: OpenAI Codex (GPT-5.6 Sol, Terra, and Luna;
human-supervised) assisted with code and tests.

Avoid rewriting or deleting hooks.toml when cleanup finds no Spec Kit-managed hooks to remove. Preserve existing cleanup behavior for managed entries.
@mnriem mnriem added the triage-nice-to-have Verdict: evidence-backed fix or greenlit feature — land after review label Sep 20, 2026
@mnriem
mnriem requested a balanced review from Copilot September 21, 2026 19:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused fix is correct and has comprehensive regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Preserves unowned Vibe hook configuration during no-op cleanup.

Changes:

  • Skips rewriting when no Spec Kit hook is removed.
  • Adds regression coverage for content, timestamps, comments, whitespace, and forced teardown.
File Description
src/​specify_cli/​events.py Adds the no-op cleanup guard.
tests/​integrations/​test_events.py Tests preservation of unowned Vibe files.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mnriem

mnriem commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

The behavioral fix and regression coverage look correct, but this reinforces the wrong ownership boundary. Vibe’s native hooks format and the lifecycle of .vibe/hooks.toml should be owned entirely by VibeIntegration, not implemented through Vibe-specific branches and helpers in the shared events.py module.

Shared event code should resolve canonical events, manage the shared dispatcher, and delegate native configuration generation and cleanup to the integration. Please move the Vibe rendering, merging, and removal behavior—including this no-op preservation rule—behind integration methods implemented by VibeIntegration.

The new regression cases should likewise live in tests/integrations/test_integration_vibe.py, alongside the existing TestVibeTomlMerging coverage, rather than expanding the shared event test module with Vibe-specific behavior.

Posted on behalf of @mnriem by GitHub Copilot (model: GPT-5.6 Sol, human-supervised); comment fully AI-drafted.

Move Vibe hook rendering and cleanup into VibeIntegration while retaining shared event lifecycle orchestration.
@WOLIKIMCHENG

Copy link
Copy Markdown
Contributor Author

Addressed the ownership feedback in 35c3767. Vibe-specific hook rendering and cleanup now live in VibeIntegration, while shared events retains dispatcher and manifest lifecycle orchestration. Regression coverage now follows the same boundary. Focused and broader event/integration tests pass.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

ASCII-only JSON escaping can produce invalid TOML for non-BMP characters.

Review effort: Balanced
Findings: None

@mnriem mnriem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please address Copilot feedback and fix test & lint errors

@WOLIKIMCHENG

Copy link
Copy Markdown
Contributor Author

Addressed the Vibe review feedback in 1359d75: hook strings now use TOML-native escaping, the hooks.toml manifest key is normalized to .vibe/hooks.toml, and parser-backed Unicode/control-character regressions were added. Focused regressions (4), the Vibe/shared-events tests (195), Ruff, and git diff --check pass.

@mnriem
mnriem requested a balanced review from Copilot September 24, 2026 12:49
@mnriem
mnriem requested a balanced review from Copilot and removed request for Copilot October 15, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Verified Unicode line-splitting behavior can misidentify and delete user-owned hooks.

1 open finding

🧠 Review effort: Balanced

Comment thread src/specify_cli/integrations/vibe/__init__.py Outdated
@mnriem

mnriem commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

Assisted-by: Codex CLI (model: gpt-5.6-terra, autonomous)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A new timestamp assertion fails on Windows because it assumes nanosecond filesystem precision.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread tests/integrations/test_integration_vibe.py
@mnriem

mnriem commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

@WOLIKIMCHENG

Copy link
Copy Markdown
Contributor Author

Thanks for flagging the Copilot feedback. I updated the Vibe cleanup test to compare against the stored filesystem mtime and am following up with the focused test results in the review thread.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The new TOML scanner controls deletion of user configuration and has a confirmed preservation regression requiring correction and human validation.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve standalone comments before retained user hook tables

src/​specify_cli/​integrations/​vibe/​__init__.py:439

Ending the managed span at the next table header also deletes standalone comments introducing that table. For example, a generated hook followed by # User safety hook: do not remove and an unowned [[hooks]] block loses the comment during both refresh and teardown, even though the user hook remains. An isolated comparison confirmed that the previous cleanup preserved this comment and the new scanner removes it.

Exclude trailing standalone comments from managed spans, while still including complete multiline values. Add regression coverage for refresh and teardown with a comment immediately before a retained user hook.

AI disclosure: GitHub Copilot (model unknown; automated review for the requester) generated this comment.

1 resolved since last review

Review effort: Balanced

@mnriem
mnriem requested a balanced review from Copilot October 21, 2026 13:56
@mnriem

mnriem commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback. If not applicable, please explain why

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The new TOML scanner determines which user-file content is deleted and warrants human validation beyond the reported regression checks.

No open issues 🎉

Review effort: Balanced

@mnriem
mnriem merged commit 7235dad into github:main Oct 21, 2026
16 checks passed
@mnriem

mnriem commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage-nice-to-have Verdict: evidence-backed fix or greenlit feature — land after review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants