diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index c397635..63691a4 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -6,14 +6,14 @@ }, "metadata": { "description": "Basalt — the trust layer for AI-generated work. Connect your AI to publish, update and share governed docs by URL.", - "version": "0.3.2" + "version": "0.3.3" }, "plugins": [ { "name": "basalt", "source": "./plugins/basalt", "description": "Connect your AI to Basalt — publish, update and share governed docs by URL. Bundles the Basalt MCP server (OAuth) + a skill that converges on it when you ask to publish or share written work.", - "version": "0.3.2", + "version": "0.3.3", "author": { "name": "Cofoundy SAC" }, diff --git a/docs/adr/0002-mdx-publish-signal-the-template-moves.md b/docs/adr/0002-mdx-publish-signal-the-template-moves.md index 548102c..8048bcb 100644 --- a/docs/adr/0002-mdx-publish-signal-the-template-moves.md +++ b/docs/adr/0002-mdx-publish-signal-the-template-moves.md @@ -3,6 +3,8 @@ - **Status:** accepted - **Date:** 2026-08-17 - **Issue:** #13 +- **Note (#19):** the orphan bucket and `is_doc()` described below were removed. The + no-vault warning moved to the CLI (`no_vault_binding`, at publish time). ## Context diff --git a/plugins/basalt/.claude-plugin/plugin.json b/plugins/basalt/.claude-plugin/plugin.json index 4a3218a..bcf09a9 100644 --- a/plugins/basalt/.claude-plugin/plugin.json +++ b/plugins/basalt/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "basalt", "description": "Connect your AI to Basalt — publish, update and share governed docs by URL. Bundles the Basalt MCP server (OAuth), a skill that converges on it when you ask to publish or share written work, and quiet session hooks (auth probe · edit tracking · publish nudge).", - "version": "0.3.2", + "version": "0.3.3", "author": { "name": "Cofoundy SAC", "url": "https://cofoundy.dev" diff --git a/plugins/basalt/commands/basalt.md b/plugins/basalt/commands/basalt.md index d32d667..4d5ecbc 100644 --- a/plugins/basalt/commands/basalt.md +++ b/plugins/basalt/commands/basalt.md @@ -30,8 +30,9 @@ next step. Follow that step instead of improvising setup. ⚠️ **On a repo's FIRST publish, check the project binding.** Without a `vault.yaml` at the docs root the CLI takes the first path segment as the space name — `docs/PRD.md` publishes as project `docs` / slug `prd` instead of project `` / slug `docs/prd`. -Exit 0, no warning, wrong space. Confirm with `basalt status --json` and check -the `project` field. It is the only failure here that does not announce itself. +Exit 0, wrong space; the only signal is a `no_vault_binding` warning on the row +(basalt-cli > 0.14.0). Confirm with `basalt status --json` and check the `project` +field. ## If it was born in this conversation (MCP) diff --git a/plugins/basalt/hooks/lib.sh b/plugins/basalt/hooks/lib.sh index 0811089..0cfc265 100755 --- a/plugins/basalt/hooks/lib.sh +++ b/plugins/basalt/hooks/lib.sh @@ -51,26 +51,10 @@ print("" if d is None else (d if isinstance(d, str) else json.dumps(d))) dirty_dir() { printf '%s/basalt-hooks' "${TMPDIR:-/tmp}"; } dirty_file() { printf '%s/dirty-%s.list' "$(dirty_dir)" "$1"; } # $1 = session_id -# --- orphan-list: docs edited with NO vault.yaml above them --------------------------- -# Publishing from a repo with no vault.yaml is the ONE Basalt failure that does not -# announce itself: with no project binding the CLI takes the first path segment as the -# space name, so `docs/PRD.md` lands as project "docs" / slug "prd" instead of -# project "" / slug "docs/prd" — exit 0, no warning, wrong space. Every other -# error here is loud; this one needs a sensor. Same shape as the dirty-list: PostToolUse -# records, Stop speaks once (batching-at-close, never push-on-edit). -orphan_file() { printf '%s/orphan-%s.list' "$(dirty_dir)" "$1"; } # $1 = session_id - -# is_doc -> 0 when the file reads as publishable prose, 1 otherwise. -# Deliberately narrow: `.mdx` anywhere (authoring it IS the intent to publish), `.md` -# only under a `docs/` directory. A README in a code repo must never trip this — a -# sensor that cries on every repo gets muted, and then it is worth less than nothing. -is_doc() { - case "$1" in - *.mdx) return 0 ;; - */docs/*.md|*/docs/*/*.md|*/docs/*/*/*.md) return 0 ;; - *) return 1 ;; - esac -} +# The orphan bucket (a doc edited with NO vault.yaml above it) lived here until #19: it +# warned at Stop about a publish that had not happened, on every doc edit in every repo. +# The risk is real only at publish time, so the CLI owns it now — `basalt publish` tags +# the row `no_vault_binding` when the space came from a folder name. # --- vault discovery: walk up from a file to the nearest vault.yaml ------------------- # find_vault -> prints the vault.yaml path, or empty if none upward. @@ -104,8 +88,7 @@ vault_policy() { # doc cannot publish — because the server REJECTS it, not because nobody tried — the only # lever was `publish: manual`, which silences every other doc in the vault too. What is # left is a nag that fires every session with no action available, which trains the reader -# to ignore the channel. The orphan bucket already decided this case ("clear either way → -# no re-nag"); this is the missing other half. +# to ignore the channel. # # name: atelier # publish: prompt diff --git a/plugins/basalt/hooks/post-edit.sh b/plugins/basalt/hooks/post-edit.sh index 44185d4..79a1249 100755 --- a/plugins/basalt/hooks/post-edit.sh +++ b/plugins/basalt/hooks/post-edit.sh @@ -19,12 +19,6 @@ sid="$(json_get "$payload" "session_id")" [ -n "$sid" ] || sid="nosession" mkdir -p "$(dirty_dir)" 2>/dev/null || exit 0 -# append_once — dedup against HISTORY. Correct for the orphan list, -# WRONG for the dirty journal. See B1 below. -append_once() { - { [ -f "$1" ] && grep -Fxq "$2" "$1"; } || printf '%s\n' "$2" >> "$1" -} - vault="$(find_vault "$file")" if [ -n "$vault" ]; then # B1 — the dirty append is UNCONDITIONAL, and this is the one blocking defect if it is @@ -35,16 +29,9 @@ if [ -n "$vault" ]; then # replay: p → live={p} ; -p → live={} → Stop goes SILENT # # That is acceptance arm (c)'s second half — "then edit it again ⇒ it nags again" — - # failing toward silence. `append_once` stays ONLY on the orphan list below, where the - # dedup is semantically required (the fix is one vault, not one per file). Dedup for - # the dirty list now happens at REPLAY, where the whole ordering is visible. + # failing toward silence. Dedup for the dirty list happens at REPLAY, where the whole + # ordering is visible. # This also REMOVES a per-edit `grep`. Zero network / zero output are untouched. printf '%s\n' "$file" >> "$(dirty_file "$sid")" # under a vault → publishable -elif is_doc "$file"; then - # A doc with no vault above it. Not an error yet — but a publish from here would land - # in the wrong space silently, so record the REPO ROOT (not the file): the fix is one - # `vault.yaml` per tree, and Stop should say it once, not once per file. - root="$(cd "$(dirname "$file")" 2>/dev/null && git rev-parse --show-toplevel 2>/dev/null)" - [ -n "$root" ] && append_once "$(orphan_file "$sid")" "$root" fi exit 0 diff --git a/plugins/basalt/hooks/stop.sh b/plugins/basalt/hooks/stop.sh index 5395b6e..732e6bb 100755 --- a/plugins/basalt/hooks/stop.sh +++ b/plugins/basalt/hooks/stop.sh @@ -37,8 +37,7 @@ payload="$(cat)" sid="$(json_get "$payload" "session_id")" [ -n "$sid" ] || sid="nosession" df="$(dirty_file "$sid")" -of="$(orphan_file "$sid")" -[ -f "$df" ] || [ -f "$of" ] || exit 0 # nothing tracked → silent +[ -f "$df" ] || exit 0 # nothing tracked → silent # 2) REPLAY the append-only journal into the live set — vault docs edited since their # last publish (A2) — then drop the ones the repo's own Action will publish @@ -62,15 +61,6 @@ if [ -f "$df" ]; then done < <(replay_journal "$df") fi -# 2b) Orphan bucket: docs edited in a repo with NO vault.yaml. Only speak when the CLI is -# actually installed — without it the user is not publishing from here and the warning is -# noise. Silence for a real user beats a warning for a hypothetical one. -orphan_root="" -if [ -f "$of" ] && command -v basalt >/dev/null 2>&1; then - orphan_root="$(head -1 "$of")" -fi -rm -f "$of" 2>/dev/null # clear either way → no re-nag - # 3) Auto bucket: one diff-aware publish. Failure / no CLI → degrade into the prompt count. published_n=0 if [ "${#auto_files[@]}" -gt 0 ]; then @@ -101,10 +91,5 @@ if [ "$prompt_n" -gt 0 ]; then fi elif [ "$published_n" -gt 0 ]; then printf 'Basalt: auto-published %d edited vault doc(s). Share the canonical URL(s) with the reader.\n' "$published_n" -elif [ -n "$orphan_root" ]; then - # The silent-failure sensor. Says the CONSEQUENCE, not the config detail — "no - # vault.yaml" means nothing to a reader who has never hit this; "goes to the wrong - # space without erroring" is why they should care before the first publish. - emit_block "Basalt: docs edited in $(basename "$orphan_root"), which has no vault.yaml — publishing from here silently lands in the wrong space (exit 0). Run \`basalt onboard\` for the fix." fi exit 0 diff --git a/plugins/basalt/hooks/tests/run.sh b/plugins/basalt/hooks/tests/run.sh index 17fcd42..2738e7b 100755 --- a/plugins/basalt/hooks/tests/run.sh +++ b/plugins/basalt/hooks/tests/run.sh @@ -119,44 +119,20 @@ PATH="$PATH_WITH_STUB" run "$pl" "$HOOKS/post-edit.sh" >/dev/null out="$(PATH="$PATH_WITH_STUB" run "$(cat "$FIX/posttooluse-no-filepath.json")" "$HOOKS/post-edit.sh")"; rc=$? { [ -z "$out" ] && [ $rc -eq 0 ]; } && ok "negative control (no file_path) → silent, exit 0" || no "negative control should be silent (out:$out rc:$rc)" -# --- orphan sensor: a doc edited where NO vault.yaml exists above it ------------------- -# The one Basalt failure that returns exit 0: with no vault.yaml there is no project -# binding, so `docs/PRD.md` publishes as project "docs" / slug "prd" instead of -# project "" / slug "docs/prd" — wrong space, no warning. PostToolUse records the -# repo root; Stop speaks once. Narrow by design: a README in a code repo must not trip it. -# `append_once` STAYS here (B1 removed it from the dirty list only): the dedup is -# semantically required — the fix is one vault.yaml, not one per file. +# --- #19: a doc edited where NO vault.yaml exists above it records NOTHING ------------ +# The orphan sensor used to record the repo root here and block at Stop on every doc edit +# in every repo — warning about a publish that had not happened. The risk is real only at +# publish time, so `basalt publish` owns it now (`no_vault_binding`). Pin the silence. reset_dirty ORPH="$WORK/orphanrepo"; mkdir -p "$ORPH/docs" -( cd "$ORPH" && git init -q && git config user.email t@example.invalid && git config user.name t ) >/dev/null 2>&1 -ORPH_REAL="$(cd "$ORPH" && git rev-parse --show-toplevel)" -OF_PE="$DDIR/orphan-$sid_pe.list" - -echo x > "$ORPH/docs/PRD.md" -pl="$(jq -c --arg f "$ORPH/docs/PRD.md" '.tool_input.file_path=$f' "$FIX/posttooluse-write.json")" -out="$(PATH="$PATH_WITH_STUB" run "$pl" "$HOOKS/post-edit.sh")" -{ [ -z "$out" ] && [ -f "$OF_PE" ] && grep -Fxq "$ORPH_REAL" "$OF_PE"; } \ - && ok "doc with no vault → repo root recorded, zero output" || no "orphan not recorded" - -echo x > "$ORPH/docs/OTHER.md" -pl="$(jq -c --arg f "$ORPH/docs/OTHER.md" '.tool_input.file_path=$f' "$FIX/posttooluse-write.json")" -PATH="$PATH_WITH_STUB" run "$pl" "$HOOKS/post-edit.sh" >/dev/null -n="$(wc -l < "$OF_PE" | tr -d ' ')" -[ "$n" = "1" ] && ok "second doc, same repo → ONE entry (append_once stays on the orphan list)" \ - || no "orphan should dedupe by repo root (entries=$n)" - -echo x > "$ORPH/README.md" -pl="$(jq -c --arg f "$ORPH/README.md" '.tool_input.file_path=$f' "$FIX/posttooluse-write.json")" -PATH="$PATH_WITH_STUB" run "$pl" "$HOOKS/post-edit.sh" >/dev/null -n="$(wc -l < "$OF_PE" | tr -d ' ')" -[ "$n" = "1" ] && ok "README in a code repo → NOT flagged (sensor stays narrow)" \ - || no "README should not trip the orphan sensor (entries=$n)" - -mkdir -p "$ORPH/src"; echo x > "$ORPH/src/note.md" -pl="$(jq -c --arg f "$ORPH/src/note.md" '.tool_input.file_path=$f' "$FIX/posttooluse-write.json")" -PATH="$PATH_WITH_STUB" run "$pl" "$HOOKS/post-edit.sh" >/dev/null -n="$(wc -l < "$OF_PE" | tr -d ' ')" -[ "$n" = "1" ] && ok "stray .md outside docs/ → NOT flagged" || no "stray .md tripped it (entries=$n)" +( cd "$ORPH" && git init -q ) >/dev/null 2>&1 +for f in docs/PRD.md docs/x.mdx; do + echo x > "$ORPH/$f" + pl="$(jq -c --arg f "$ORPH/$f" '.tool_input.file_path=$f' "$FIX/posttooluse-write.json")" + out="$(PATH="$PATH_WITH_STUB" run "$pl" "$HOOKS/post-edit.sh")" + { [ -z "$out" ] && [ -z "$(ls -A "$DDIR" 2>/dev/null)" ]; } \ + && ok "#19: $f with no vault → nothing recorded, zero output" || no "#19: $f should record nothing" +done out="$(PATH="$PATH_WITH_STUB" run "$(cat "$FIX/malformed.json")" "$HOOKS/post-edit.sh")"; rc=$? { [ -z "$out" ] && [ $rc -eq 0 ]; } && ok "malformed payload → silent, exit 0" || no "malformed should be silent (out:$out rc:$rc)" @@ -375,35 +351,13 @@ printf '%s\n-%s\n' "$D" "$D" > "$DF_STOP" out="$(PATH="$PATH_WITH_STUB" run "$(cat "$FIX/stop-inactive.json")" "$HOOKS/stop.sh")" [ -z "$out" ] && ok "journal replaying to an empty live set → silent" || no "tombstoned doc should be silent (got: $out)" -# --- orphan sensor at Stop ------------------------------------------------------------- -OF_STOP="$DDIR/orphan-$sid_stop.list" - -reset_dirty; mkdir -p "$DDIR"; printf '%s\n' "$WORK/myrepo" > "$OF_STOP" -out="$(PATH="$PATH_WITH_STUB" run "$(cat "$FIX/stop-inactive.json")" "$HOOKS/stop.sh")" -printf '%s' "$out" | jq -e '.decision=="block" and (.reason|test("no vault.yaml"))' >/dev/null 2>&1 \ - && ok "orphan repo + CLI → block nudge naming the silent failure" || no "orphan should nudge (got: $out)" -r="$(printf '%s' "$out" | jq -r .reason)" -[ "${#r}" -le 200 ] && ok "budget: orphan reason ${#r}B ≤ 200B" || no "orphan reason too long (${#r}B)" -[ ! -f "$OF_STOP" ] && ok "orphan list cleared after speaking → no re-nag" || no "orphan list should clear" - -# No CLI → the user is not publishing from here; the warning would be noise. -reset_dirty; mkdir -p "$DDIR"; printf '%s\n' "$WORK/myrepo" > "$OF_STOP" -out="$(PATH="$PATH_NO_BASALT" run "$(cat "$FIX/stop-inactive.json")" "$HOOKS/stop.sh")" -[ -z "$out" ] && ok "orphan + no CLI → SILENT (not a Basalt user, not their problem)" \ - || no "orphan without CLI should stay silent (got: $out)" - -# A real dirty doc outranks the orphan hint: a pending publish beats a setup warning. -reset_dirty; mkdir -p "$DDIR"; D="$(mk_vault "$WORK/vorph" prompt)" -printf '%s\n' "$D" > "$DF_STOP"; printf '%s\n' "$WORK/myrepo" > "$OF_STOP" +# --- #19: a no-vault doc edit reaches Stop as SILENCE, never a block ------------------- +reset_dirty +pl="$(jq -c --arg f "$ORPH/docs/PRD.md" --arg s "$sid_stop" '.tool_input.file_path=$f | .session_id=$s' "$FIX/posttooluse-write.json")" +PATH="$PATH_WITH_STUB" run "$pl" "$HOOKS/post-edit.sh" >/dev/null out="$(PATH="$PATH_WITH_STUB" run "$(cat "$FIX/stop-inactive.json")" "$HOOKS/stop.sh")" -printf '%s' "$out" | jq -e '.reason|test("unpublished")' >/dev/null 2>&1 \ - && ok "dirty doc outranks orphan hint (one message, the actionable one)" || no "dirty should win (got: $out)" - -# Loop guard must cover the orphan path too, or Stop nags forever. -reset_dirty; mkdir -p "$DDIR"; printf '%s\n' "$WORK/myrepo" > "$OF_STOP" -out="$(PATH="$PATH_WITH_STUB" run "$(cat "$FIX/stop-active-guard.json")" "$HOOKS/stop.sh")"; rc=$? -{ [ -z "$out" ] && [ $rc -eq 0 ]; } && ok "orphan + stop_hook_active → silent (loop guard holds)" \ - || no "orphan must respect the loop guard (out:$out rc:$rc)" +[ -z "$out" ] && ok "#19: no-vault doc edit + CLI installed → Stop silent (no block)" \ + || no "#19: Stop must not block on a no-vault edit (got: $out)" echo "── stop.sh — Mechanism B (the #4 repo-backed-vault case) ────" # The mandated flow for a repo-backed vault is commit + push → the repo's Action diff --git a/plugins/basalt/skills/basalt/references/cli-path.md b/plugins/basalt/skills/basalt/references/cli-path.md index 12bd004..0235c33 100644 --- a/plugins/basalt/skills/basalt/references/cli-path.md +++ b/plugins/basalt/skills/basalt/references/cli-path.md @@ -31,13 +31,14 @@ Without a `vault.yaml` at the docs root there is no project binding, so the CLI **first path segment as the space name**: ``` -no vault.yaml docs/PRD.md → project "docs", slug "prd" exit 0, no warning +no vault.yaml docs/PRD.md → project "docs", slug "prd" exit 0, warning no_vault_binding with vault.yaml docs/PRD.md → project "", slug "docs/prd" ``` -The publish reports success and lands in a space nobody meant to create. Every other -error in this system is loud; this one is not. Before the first publish in a repo, -confirm the binding: +The publish reports success and lands in a space nobody meant to create. It exits 0; +since basalt-cli > 0.14.0 the row carries a `no_vault_binding` warning naming the space it +resolved (older CLIs print nothing). Read the warnings, and before the first publish in +a repo confirm the binding: ```bash basalt status --json # the `project` field must be the intended space