Skip to content

chore: guard sensitive paths and flag stale knowledge notes - #5140

Merged
joanagmaia merged 2 commits into
mainfrom
chore/agent-guardrails
Oct 28, 2026
Merged

joanagmaia merged 2 commits into
mainfrom
chore/agent-guardrails

Conversation

@joanagmaia

Copy link
Copy Markdown
Contributor

Summary

Phase 4 of the agent-ready knowledge base. Claude Code now warns before it edits migrations, auth, data deletion and production config. It also reminds Claude to update a knowledge note when it edits code that the note lists under sources.

Changes

  • guard-protected-files.sh: adds the osspckgs and product Flyway migration directories, backend and public API auth, frontend auth, member erasure scripts, cleanup jobs and workflows, unmerge, */config/production.json, and production deploy workflows. It only warns and never blocks an edit.
  • New knowledge-doc-check.sh PostToolUse hook. It reads the sources list in each docs/knowledge/*.md frontmatter. A source ending in / covers everything below it. When an edited file matches, the hook returns additionalContext naming the note, so the reminder reaches Claude and not only the transcript. It skips edits to the notes themselves.
  • docs/knowledge/README.md: one sentence about the hook.

The same knowledge hook goes into insights in a companion PR.

Type of change

  • Chore / dependency update

Related issue

None. This is local work with no ops issue.

Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Copilot AI balanced review requested due to automatic review settings October 28, 2026 11:17
@cursor

cursor Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Changes only affect local Claude Code hooks and docs; they warn or add context and do not alter runtime application behavior.

Overview
Claude Code guardrails get broader coverage and a new post-edit reminder for docs/knowledge notes.

guard-protected-files.sh now warns (still non-blocking) on edits to osspckgs/product Flyway migrations, backend/public/frontend auth, GDPR erasure and bulk cleanup paths, unmerge, production.json / env-var config, and production deploy workflows—replacing the single backend migration if with grouped case patterns.

A new knowledge-doc-check.sh PostToolUse hook scans each note’s frontmatter sources (including directory prefixes ending in /); when an edited file matches, it injects additionalContext telling the agent to update the note in the same PR. It skips edits under docs/knowledge/*. .claude/settings.json chains this hook after oxlint/oxfmt on Edit/Write; docs/knowledge/README.md documents the behavior.

Reviewed by Cursor Bugbot for commit 26f4739. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; both previous findings are addressed and no new actionable issue was found.

Summary

Adds advisory warnings for sensitive files and reminds Claude Code when edited code is listed as a knowledge note's source.

  • Claude Code warns before edits to more sensitive paths.
  • Claude Code gets a reminder when edited code is listed as a knowledge-note source.

Reviews (2) · Last reviewed commit: "fix: read inline source lists and drop h..." · Reviewed by Greptile

Comment thread .claude/hooks/knowledge-doc-check.sh Resolved
Comment thread .claude/hooks/knowledge-doc-check.sh Resolved

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

The documented sources: [...] template is incompatible with the hook’s block-list-only parser, so notes following the template will not receive reminders.

1 open issue
What changed in this PR

This PR expands Claude Code’s advisory safeguards for sensitive CDP files and adds reminders to keep knowledge notes aligned with their source code.

Changes:

  • Extends non-blocking warnings to additional migration, authentication, deletion, unmerge, and production paths.
  • Registers a post-edit hook that identifies related knowledge notes and returns reminders through additionalContext.
  • Documents the reminder hook and directory-prefix matching.
File Description
docs/​knowledge/​README.md Documents knowledge-note reminders and directory matching.
.claude/​settings.json Registers the knowledge-check hook after edits.
.claude/​hooks/​knowledge-doc-check.sh Matches edited files to note sources and emits reminders.
.claude/​hooks/​guard-protected-files.sh Expands sensitive-path warning coverage.

Review effort: Balanced

Comment thread docs/knowledge/README.md Resolved
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Copilot AI balanced review requested due to automatic review settings October 28, 2026 11:24

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.

🟢 Approval recommended

No active review issues require changes to the sensitive-path warnings or knowledge-note reminders.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@joanagmaia
joanagmaia merged commit 2981813 into main Oct 28, 2026
15 checks passed
@joanagmaia
joanagmaia deleted the chore/agent-guardrails branch October 28, 2026 11:49
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