Reorganizing notes into content categories does not update the code that saves the next note. If that code still defaults to the old shared folder, it can recreate the location you just retired.
My AI assistant had a note tool that appended to a project folder when a project was supplied, and to a shared location otherwise. After reorganizing the notes, I changed that fallback into an explicit destination check.
A new default would keep the same ambiguity
Replacing the old shared path with the root of the new knowledge folder would still collect unclassified notes in one place.
Instead, a save without a project must specify an existing content category. Missing both inputs, supplying an unknown category, or supplying both a project and a category now produces an error without saving.
The implementation follows this simplified order:
Trim the project and category names
→ Reject both being supplied
→ Keep the existing project route when a project is supplied
→ Otherwise check the category against the existing allowlist
→ Reject a missing or unknown category
→ Only then resolve the destination, create directories, and append
The checks sit before directory creation. That gives the tests a useful negative condition: an unclassified note must not create even the save root.
Keep the tool contract and the writer in agreement
I added the category enum to the model-facing tool definition, updated its Japanese and English descriptions, and passed the category through the tool consumer to the saving function.
The saving function also checks the allowlist. A description telling the model to choose a category is not the only place enforcing the rule. When both a project and a category arrive, the writer rejects the ambiguity rather than silently choosing one.
This establishes a no-write condition and a model-facing instruction. It does not demonstrate that an interactive clarification screen has worked in the real app.
Test refusal as well as successful appends
The saved tests use temporary folders and dummy data:
| Input or operation | Verified result |
|---|---|
| Neither project nor category | Error; the save root is not created |
| Unknown or path-like category | Error; the save root is not created |
| Both project and category | Error; no destination is silently preferred |
| Append to an existing note in a valid category | Existing filename and original byte prefix remain; the addition is present |
| Category supplied through the tool consumer | Writes into the selected content category |
| Project supplied through the tool consumer | Keeps the existing project route |
| Japanese and English tool definitions | Category input and contract consistency are checked |
The assistant-side result is 57 passing tests across three files, including existing tests. These are not 57 newly added tests. The main-layer TypeScript typecheck also passed.
A separate mock test covers the related one-way note generator. It runs the actual generation body with a temporary home and guarded filesystem access. It checks the new category destination, the location of the entry note, preservation of manually written originals, and absence of the retired folder.
Applied source is a different result from working software
I reviewed the saved patch and results from October 21, 2026, Japan time. The record covers three runtime source files and four related test files, with hashes confirming that the applied bytes matched the tested bytes. I did not rerun these tests for this article.
The record does not establish a packaged build, a running assistant saving notes in the real vault, or a real synchronization run. The generator's existing cleanup behavior was not redesigned. Before a real sync, preserving manual additions made after the move still needs separate checking.
Rejecting path-like category strings also does not prove safety against every path operation, symlink, or concurrent write.
The change is small: when a note's destination cannot be determined, a convenient default must not carry it into a write. The rule belongs in the writer and its no-write tests, as well as in the instructions given to the model.
This article summarizes implementation and saved validation records. AI assisted the implementation, validation, and the organization and writing of this article.
Top comments (0)