Validate tab_clip vault overrides against the Obsidian registry - #16
Merged
Conversation
Cleanup on the check added in b3bb926, no behavior change beyond one softening. - The lookup answered with `{name, path}` pairs and nothing ever read `path`. It now answers with names, which drops the exported interface, the dedup Map, and the `.name` unwrapping at every call site. - `parseObsidianVaultRegistry` used a private fourth copy of `asRecord`; it imports the shared guard the rest of gullet already uses. - `validateVaultOverride` ran the whole `parseTabClipParams` to read one field, so gullet was also re-validating `tabId` and `close` — which the extension owns — and reporting those errors from a function named for the vault. `parseVaultOverride` is exported instead. - The lookup did `exists()` and then read `lastModified`/`size`, two stats per call; one `stat()` now does both, and a missing file throws into the same soft catch. - `knownObsidianVaults` is optional, matching `rivalHubs?` — it can refuse a call it can prove wrong, but an absent lookup never changes one, and every construction site no longer needs a stub. - An empty `vaults: {}` registry is "cannot check" rather than a hard rejection listing "(none)". That state proves nothing about a name the user read off their own vault switcher, so it belongs with the other soft cases. Verified: bun run typecheck, test (398 pass), format, lint:js.
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
tab_clipaccepts avaultoverride, and until now nothing could tell a caller that the name was wrong. The handoff is anobsidian://URL given to the OS: an unrecognised vault fails inside Obsidian, where neither end of the bridge can observe it, and the call still reports success.Gullet now checks an explicit
vaultname against Obsidian's localobsidian.jsonregistry before forwarding it. A readable, understood registry that does not contain the name produces abad-requestlisting the vaults that registry knows.Deliberately a soft check
The registry is undocumented and incomplete, and its location varies outside a standard install. So absent, unreadable, malformed, unfamiliar, or empty (
vaults: {}) all preserve the old pass-through behavior — only a registry that positively contradicts the name refuses the call. An empty registry proves nothing about a name the user read off their own vault switcher, so it belongs with the other soft cases rather than producing a rejection listing "(none)".The error describes known vaults rather than claiming to enumerate every vault on disk. The extension still cannot validate the destination.
Parsed contents are cached by modification time and size (one
stat()per call), so a vault added while Gullet is running appears on the next changed-file check.Notes
knownObsidianVaultsis optional onToolContext, matchingrivalHubs?— it can refuse a call it can prove wrong, but an absent lookup never changes one, so construction sites need no stub.parseVaultOverrideis exported so the vault check reads only the vault field. It previously ran the wholeparseTabClipParams, meaning Gullet re-validatedtabIdandclose— which the extension owns — and reported those errors from a function named for the vault.vaultWarningForpath-vs-name check is unchanged.Verification
bun run typecheck,bun test(398 pass),bun run format:check,bun run lint:js.No manifest or permission changes. No UI changes.