Skip to content

feat(knowledge): edit a folder source's ignore patterns after adding it - #31410

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/17371-edit-folder-ignore-patterns
Nov 7, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/17371-edit-folder-ignore-patterns

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Let a user change a local folder source's ignore patterns after adding it, without removing the source and without losing anything already indexed.

A folder source's ignore patterns can only be set in the add-source form. A pattern missed at that point (for example a generated subfolder of ~1,600 notes) leaves two bad options: remove the source and index the whole folder again, or hand-edit the stored properties.

Why it matters

Large folders and vaults are the sources most likely to need a pattern added later, and the most expensive to index again. Re-adding a source throws away its indexing progress and spends model calls on content that was already in the Library.

Not a goal

  • Removing already-indexed files that a new pattern matches. The maintainer ruling on Knowledge: allow editing a folder source's ignore patterns after it is added #17371 says they are kept and frozen; an explicit purge option comes in a later PR.
  • Editing other folder-source settings (recursion, file cap, minimum size, extensions).
  • Changing how .kiroignore, the sensitive-path guard, confine_to_root or the extension and size filters treat a file they exclude: they still remove it on the next sweep.
  • Starting a sweep on save: the next scheduled sweep applies the patterns.

What changed (motivation → approach → change)

Opening a folder row in the Knowledge panel now shows its ignore patterns in an editable box with a Save patterns button. Saving changes which files future sweeps pick up. It never removes anything already indexed.

Part Change
API PATCH /api/knowledge/sources/{id} (dashboard/handlers/knowledge_sources.py) accepts ignore_patterns on a local_folder or obsidian_vault source: a list of strings, trimmed, blank lines dropped. name is optional when patterns are sent, and every field is checked before anything is written. The write goes through merge_source_properties, so other properties are kept; a source deleted mid-request gets 404 source_not_found and no audit line. Each refusal carries a code.
Sweep folder_watcher.py keeps a tracked file that only the ignore patterns now exclude, as long as its row still holds indexed items. That file is frozen: it is not re-read and gets no last_seen updates. Deleting the file, or any other rule excluding it, still archives it. Only tracked files go through the remaining rules before the pattern decides. Any other matched file is dropped before it is resolved or stat'ed, as on main. A kept row left pending (a Retry) or scanning (an interrupted re-read) is written done with an empty bytes hash, so progress completes and a later un-ignore re-reads the file.
UI IgnorePatternsEditor.tsx sits in the expanded folder view above the progress list. A visible Ignore patterns label names the box. A visible line under it gives the format (one pattern per line, matched against the file's path inside the folder; * matches any characters, / included; case-sensitive) and describes the box, so it stays when saved patterns hide the placeholder. It has a hint that matching indexed files are kept and no longer updated, and it shows errors through ErrorNotice. Three new catalog keys are added in all 12 locales under website/src/i18n/locales/, and en-XA is regenerated.
Docs The knowledge.md spec describes the edit route and the keep rule. The feature map lists the editor and the route. The kiroignore.py and bundle_ownership.py comments are updated to match the keep rule.

A kept AsciiDoc includer keeps the included text it was indexed with, like any other frozen copy.

Backwards compatibility

Breaking: the route now checks ignore_patterns when it is sent. On main it ignored every key except name. So {"name": ..., "ignore_patterns": <not a list of strings>}, or ignore_patterns sent to a non-folder source, used to succeed and is now refused with 400. {"name": ...} alone behaves as before. Writer sweep on origin/main @ 665a0e4: the only caller that sends PATCH to /api/knowledge/sources/{id} is the Sources list rename, and it sends { name } only. No app, CLI, MCP tool or doc calls this route.

Behaviour change: on main, the next sweep archives a tracked file that newly matches ignore_patterns. That case was only reachable by hand-editing the stored properties. Such a file is now kept, as the maintainer ruling on #17371 asks.

Reader: website/src/pages/knowledge/SourcesList.tsx:renameMutation -- crew page -- sends { name } only; website/src/test/SourcesList.rename.test.tsx
Reader: src/kiro_crew/knowledge/folder_watcher.py:FolderWatcher._do_scan -- crew page -- the step-4 removal still archives every row a non-pattern rule excludes; test/test_folder_watcher.py::TestEditedIgnorePatterns::test_a_newly_ignored_file_another_rule_excludes_is_still_archived

Tests

  • test/test_folder_watcher.py::TestEditedIgnorePatterns: an indexed file that a new pattern matches keeps its row and items and is not re-ingested, even when edited. This holds for a done row and for a failed row that still holds items. A kept row in pending or scanning ends done after one sweep and is re-read once the pattern is dropped. A new file under the pattern is not ingested. A file that .kiroignore also excludes is still archived, which pins that patterns are tested after every other rule.
  • test/test_folder_watch_handlers.py::TestEditIgnorePatterns: patterns are trimmed and blanks dropped, other properties and the name are kept, a non-folder source or a non-list value is refused without any write, and a source deleted before the write gets 404.
  • website/src/test/SourcesList.ignorePatterns.test.tsx: the expanded folder row shows the saved patterns, the box has a visible label bound to it and is described by the format line, Save stays disabled until they change, and the edited list is PATCHed trimmed.
  • Determinism (D12): the new backend tests passed 20 times at -n0, 10 times at -n 4 beside their files' other tests, and once in a shuffled order.

Proof: PROVEN test/test_folder_watch_handlers.py::TestEditIgnorePatterns::test_a_folder_source_takes_trimmed_patterns_and_keeps_its_other_properties, test/test_folder_watch_handlers.py::TestEditIgnorePatterns::test_a_non_folder_source_or_a_non_list_is_refused_unwritten[local_file-patterns0], test/test_folder_watch_handlers.py::TestEditIgnorePatterns::test_a_non_folder_source_or_a_non_list_is_refused_unwritten[local_folder-sub/*], test/test_folder_watch_handlers.py::TestEditIgnorePatterns::test_a_non_folder_source_or_a_non_list_is_refused_unwritten[local_folder-patterns2], test/test_folder_watch_handlers.py::TestEditIgnorePatterns::test_a_source_deleted_before_the_write_is_a_404_not_a_success (head b4796960d87b)

Manual verification

The real IgnorePatternsEditor was rendered in a throwaway capture page with a saved pattern list, served by a Vite dev server on 127.0.0.1, and shot with Playwright in both themes. The label, box, hint and Save button render as shown below. The backend was checked by the unit tests above.

Screenshots / video

The pattern editor with its visible label and saved patterns (dark, light):

Ignore patterns editor, dark theme

Ignore patterns editor, light theme

Related Issues

Closes #17371

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 12:25
@bolichen97
bolichen97 requested a review from Zedmor November 6, 2026 12:25
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of cd7d81228f8f21f2dd3efe5ba61e55213ee0c101 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the edit route is narrow, every field is checked before anything is written, and the keep-and-freeze rule matches the maintainer ruling on #17371.

Notes

  • If a pattern is later removed, a kept file is re-read only when its row was moved pending/scanning→done with an empty hash. A done row that was edited while ignored relies on mtime to pick up the change. The spec should state which of these is intended.

[DESIGN-REVIEWED] cd7d812

Description read

[DESCRIPTION-READ] 18f8261fa0da74dccee11ad32791cf124bf279b475298170398c228aa968ad74

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of cd7d81228f8f21f2dd3efe5ba61e55213ee0c101 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. Every item serves the frozen Goal: edit a folder source's patterns without losing indexed content. The keep rule is the "without losing anything" half of that Goal, not a rider.

Not checked: the maintainer ruling on #17371 that kept files stay frozen; the issue is not readable here.

Notes

What this change ships

Inventory (7 items) — 6 justified

Intent: let a user change a folder source's ignore patterns after adding it, keeping what is already indexed. ADDITION.

  1. An expanded folder row shows an editable "Ignore patterns" box with a Save patterns button — justified
  2. PATCH /api/knowledge/sources/{id} accepts ignore_patterns, and name becomes optional — justified
  3. A malformed ignore_patterns, or one sent to a non-folder source, is now refused with 400 where it used to be silently ignored — justified
  4. A source deleted mid-save returns 404 source_not_found and writes no audit line — justified
  5. A sweep keeps, frozen, an indexed file that only the patterns now exclude, where it used to archive it — inherited: the provenance is a ruling quoted from an issue
  6. A kept row left pending or scanning is written done with an empty hash — justified
  7. A new SEL audit event source.ignore_patterns — justified

[FIRST-PRINCIPLES-REVIEWED] cd7d812

Description read

[DESCRIPTION-READ] ec4cb219fcd858c09cdac850babd7750f07e68f037266593bb138fc2c5fd8ed0

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

UX-level review of cd7d81228f8f21f2dd3efe5ba61e55213ee0c101 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

cannot evaluate: missing the ignore_patterns_help format line. Both screenshots come from an older revision. They show no format line, so the blind reader could not tell what * and ** mean, and that text exists to answer exactly that.

Evidence gaps

  • Format line (ignore_patterns_help: "One pattern per line, matched against each file's path inside this folder. * matches any characters, including /. …"). IgnorePatternsEditor.tsx renders it between the label and the box, and the description says it is there ("A visible line under it gives the format"). Neither shot-01 nor shot-02 shows it, so that claim is not visible in the pixels. Fix: new dark and light screenshots of the current head.
  • The editor inside its folder row. Both shots crop to the editor alone. The reader said: "I do not know what this list applies to." Fix: one screenshot of the expanded folder row, showing the editor above the progress list.
  • Edited and failed states. No shot shows Save enabled after an edit, or the inline ErrorNotice after a refused save. Fix: one screenshot of each.

Notes

  • The disabled Save patterns button nearly disappears in light theme. The reader wrote: "very pale and hard to see at all." Check its contrast against the light background.
  • The example pattern generated/** suggests ** means something different from *. Per the help text it does not. Use generated/* in the examples so readers don't think there are two rules.
  • "kept and no longer updated" does not say how to remove those files, and the reader found it "a little worrying." Either add that a cleanup option is coming, or have the reader confirm the current line reads fine as is.

[UX-REVIEWED] cd7d812

Description read

[DESCRIPTION-READ] a32471fa6e02207d8ca12799e84993dee4576290c0d4e169a215d84176370064

That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of cd7d81228f8f21f2dd3efe5ba61e55213ee0c101 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] cd7d812

False positive or not applicable? A repository writer can comment:
/ai-review override gpt cd7d81228f8f21f2dd3efe5ba61e55213ee0c101 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed cd7d81228f8f21f2dd3efe5ba61e55213ee0c101 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] cd7d812

Verdict parsed from the review's SHA-scoped output markers for commit cd7d81228f8f21f2dd3efe5ba61e55213ee0c101.

False positive or not applicable? A repository writer can comment:
/ai-review override fable cd7d81228f8f21f2dd3efe5ba61e55213ee0c101 false-positive: <reason, 20 to 500 characters>

@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 12:43
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/17371-edit-folder-ignore-patterns branch from 758a435 to dabfcb2 Compare November 6, 2026 17:51
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 6, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: kept pattern-ignored rows settle to a terminal status

  • span=7a6e422a2256 Retry on a pattern-ignored kept row left it pending forever

fixed in dabfcb2: after the deletion step, each kept pattern-ignored row whose status is not terminal (pending after Retry, scanning after an interrupted re-read) is written done with its items and an empty bytes hash.
Progress completes and the spend count stops treating it as outstanding; once the pattern is dropped the empty hash makes the next sweep re-read the file.
Red/green: test_a_kept_ignored_file_in_flight_settles_after_one_scan[pending|scanning] fails without the fix and passes with it.

@bolichen97

bolichen97 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=9dcc528d486d The ignore-patterns textarea has no visible label

fixed in dabfcb2: a visible "Ignore patterns" label now sits above the box, bound to it with htmlFor/useId, using the existing catalog key; the hint below still says matching indexed files are kept and no longer updated.
The PR body's screenshots were re-captured at this head and show the label in both themes; the frontend test asserts the label is visible and bound to the box.

@bolichen97
bolichen97 force-pushed the fix/17371-edit-folder-ignore-patterns branch from dabfcb2 to 9c97577 Compare November 6, 2026 18:42
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 2) and Backend Tests (Windows) (2) fail on test/test_security_gate_liveness.py::test_the_package_stays_within_its_line_budget, which is red on main as well (this PR touches nothing under src/kiro_crew/security). #31625 raises that budget; this PR will rebase onto it once it merges. The other reds on 9c97577 (facade manifest entry, bn/hi register for the Save button) are fixed in the next push.

@bolichen97 bolichen97 closed this Nov 6, 2026
auto-merge was automatically disabled November 6, 2026 19:25

Pull request was closed

@bolichen97
bolichen97 force-pushed the fix/17371-edit-folder-ignore-patterns branch from 9c97577 to a31eccd Compare November 6, 2026 19:25
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 6, 2026
@bolichen97 bolichen97 reopened this Nov 6, 2026
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/17371-edit-folder-ignore-patterns branch from bee8b94 to 45239da Compare November 6, 2026 20:04
@bolichen97

Copy link
Copy Markdown
Contributor Author

On 45239da every review lane passes. The remaining reds are both main's: test_the_package_stays_within_its_line_budget (fixed by #31625, now merged) and test_pull_request_target_allowlist.py::test_only_the_allowed_workflows_use_pull_request_target (tracked in #31771, no fix merged yet). This PR touches neither area; it will rebase once the #31771 fix lands.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/17371-edit-folder-ignore-patterns branch from 45239da to ad6f83e Compare November 7, 2026 02:48
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 7, 2026
A folder source's ignore patterns could only be set when the source was
added; fixing a missed pattern meant removing the source and indexing
the whole folder again. The expanded folder row in the Knowledge panel
now has a pattern editor, and PATCH /api/knowledge/sources/{id} accepts
ignore_patterns for a folder source.

An edit never removes indexed content: the folder sweep keeps an
indexed file that only the ignore patterns now exclude, and stops
updating it. Deleting the file, or any other rule excluding it, still
removes it as before. Purging already-indexed matches is left for a
later change.

Closes #17371
@bolichen97
bolichen97 force-pushed the fix/17371-edit-folder-ignore-patterns branch from ad6f83e to cd7d812 Compare November 7, 2026 04:52
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 7, 2026

@KiroCrewCaptain KiroCrewCaptain 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.

Approved for the on-call. Review lanes pass on cd7d812, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit 503511c into main Nov 7, 2026
97 of 106 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/17371-edit-folder-ignore-patterns branch November 7, 2026 06:07
bolichen97 added a commit that referenced this pull request Nov 9, 2026
(cherry picked from commit ee46876)

Backport note: the 13 locale files and knowledgeUtils.ts add only this fix's pending_import_budget key and pendingReason field; main's adjacent last_search_* keys and ignorePatterns field come from features not on release/0.12.0 (#31410 for ignorePatterns).
bolichen97 pushed a commit that referenced this pull request Nov 9, 2026
…hile they save (#33453)

A native disabled button leaves the tab order, so pressing one from the
keyboard drops focus to the page until the request settles. Mark each busy
button aria-disabled (and aria-busy) and guard the press instead, the way
the knowledge Generate now button already does. Visual disabled styling is
unchanged. The ignore-pattern Save keeps its native disabled only for the
unchanged (nothing-to-save) state, which is inert, not in flight.

Co-authored-by: kirocrew-agent <agent@kirocrew.local>

Backport note: release has no IgnorePatternsEditor.tsx (the editor
comes from feat #31410, unreleased), so only the DetailView hunks are
taken, and the test drops its ignore-patterns Save case.

(cherry picked from commit 359e4ef)
bolichen97 pushed a commit that referenced this pull request Nov 9, 2026
…hile they save (#33453)

A native disabled button leaves the tab order, so pressing one from the
keyboard drops focus to the page until the request settles. Mark each busy
button aria-disabled (and aria-busy) and guard the press instead, the way
the knowledge Generate now button already does. Visual disabled styling is
unchanged. The ignore-pattern Save keeps its native disabled only for the
unchanged (nothing-to-save) state, which is inert, not in flight.

Co-authored-by: kirocrew-agent <agent@kirocrew.local>

Backport note: release has no IgnorePatternsEditor.tsx (the editor
comes from feat #31410, unreleased), so only the DetailView hunks are
taken, and the test drops its ignore-patterns Save case.

(cherry picked from commit 359e4ef)
bolichen97 pushed a commit that referenced this pull request Nov 10, 2026
os.walk skips a directory it cannot list, and the folder walk skipped
a file it could not stat. Either can be transient: a permission
change, or a network mount that drops out mid-walk. The scan then
read every tracked file in that gap as deleted and removed its
indexed items, which only a fresh, paid re-ingest brings back.

Record the directories the walk could not list and the files it
could not stat, and keep their rows and items. A file that is
really gone is still removed.

A file whose stat answers not-found (or not-a-directory) is gone, so it is still removed:
it was deleted after the listing, or it is a symlink whose target is
gone. An AsciiDoc includer whose target the walk could not see keeps
its indexed text too.

Backport note: conflicts only where main's hunks sit next to the
ignore-pattern keep of #31410 (unreleased). folder_watcher.py adds the
unlisted and unlisted_real sets to release's step 1 walk call (which
has no tracked or pattern_ignored arguments) and the not-unseen check to
release's removed list; _walk gains only the two new keywords.
knowledge.md adds the two new sentences to release's bullets, without
main's ignore_patterns paragraph. The test applies as on main.

(cherry picked from commit 73e3275)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Knowledge: allow editing a folder source's ignore patterns after it is added

2 participants