@onlooker-community/ecosystem 0.43.4 → 0.43.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.release-please-manifest.json +17 -17
  3. package/AGENTS.md +5 -0
  4. package/CHANGELOG.md +16 -0
  5. package/CLAUDE.md +5 -0
  6. package/docs/architecture.md +2 -2
  7. package/docs/lesson-promotion-pipeline.md +9 -1
  8. package/package.json +1 -1
  9. package/plugins/archivist/.claude-plugin/plugin.json +1 -1
  10. package/plugins/archivist/CHANGELOG.md +7 -0
  11. package/plugins/archivist/scripts/lib/archivist-config.sh +6 -2
  12. package/plugins/assayer/.claude-plugin/plugin.json +1 -1
  13. package/plugins/assayer/CHANGELOG.md +7 -0
  14. package/plugins/assayer/scripts/lib/assayer-config.sh +6 -2
  15. package/plugins/bursar/.claude-plugin/plugin.json +1 -1
  16. package/plugins/bursar/CHANGELOG.md +7 -0
  17. package/plugins/bursar/scripts/lib/bursar-config.sh +6 -2
  18. package/plugins/cartographer/.claude-plugin/plugin.json +1 -1
  19. package/plugins/cartographer/CHANGELOG.md +7 -0
  20. package/plugins/cartographer/scripts/lib/cartographer-config.sh +6 -2
  21. package/plugins/compass/.claude-plugin/plugin.json +1 -1
  22. package/plugins/compass/CHANGELOG.md +7 -0
  23. package/plugins/compass/scripts/lib/compass-config.sh +6 -2
  24. package/plugins/counsel/.claude-plugin/plugin.json +1 -1
  25. package/plugins/counsel/CHANGELOG.md +7 -0
  26. package/plugins/counsel/scripts/lib/counsel-config.sh +6 -2
  27. package/plugins/curator/.claude-plugin/plugin.json +1 -1
  28. package/plugins/curator/CHANGELOG.md +7 -0
  29. package/plugins/curator/scripts/lib/curator-config.sh +6 -2
  30. package/plugins/echo/.claude-plugin/plugin.json +1 -1
  31. package/plugins/echo/CHANGELOG.md +7 -0
  32. package/plugins/echo/scripts/lib/echo-config.sh +6 -2
  33. package/plugins/governor/.claude-plugin/plugin.json +1 -1
  34. package/plugins/governor/CHANGELOG.md +7 -0
  35. package/plugins/governor/scripts/lib/governor-config.sh +6 -2
  36. package/plugins/historian/.claude-plugin/plugin.json +1 -1
  37. package/plugins/historian/CHANGELOG.md +7 -0
  38. package/plugins/historian/scripts/lib/historian-config.sh +6 -2
  39. package/plugins/inspector/.claude-plugin/plugin.json +1 -1
  40. package/plugins/inspector/CHANGELOG.md +14 -0
  41. package/plugins/inspector/scripts/hooks/inspector-post-write.sh +4 -8
  42. package/plugins/inspector/scripts/lib/inspector-config.sh +6 -2
  43. package/plugins/inspector/scripts/lib/inspector-project-key.sh +59 -2
  44. package/plugins/librarian/.claude-plugin/plugin.json +1 -1
  45. package/plugins/librarian/CHANGELOG.md +8 -0
  46. package/plugins/librarian/scripts/lib/librarian-config.sh +6 -2
  47. package/plugins/librarian/scripts/lib/librarian-lesson-promote.sh +22 -2
  48. package/plugins/librarian/scripts/lib/librarian-lesson-storage.sh +19 -1
  49. package/plugins/lineage/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lineage/CHANGELOG.md +7 -0
  51. package/plugins/lineage/scripts/lib/lineage-config.sh +6 -2
  52. package/plugins/scribe/.claude-plugin/plugin.json +1 -1
  53. package/plugins/scribe/CHANGELOG.md +7 -0
  54. package/plugins/scribe/scripts/lib/scribe-config.sh +6 -2
  55. package/plugins/tribunal/.claude-plugin/plugin.json +1 -1
  56. package/plugins/tribunal/CHANGELOG.md +7 -0
  57. package/plugins/tribunal/scripts/lib/tribunal-config.sh +6 -2
  58. package/plugins/warden/.claude-plugin/plugin.json +1 -1
  59. package/plugins/warden/CHANGELOG.md +7 -0
  60. package/plugins/warden/scripts/lib/warden-config.sh +6 -2
  61. package/scripts/lib/config-loader.sh +15 -2
  62. package/scripts/lib/validate-path.sh +29 -38
  63. package/test/bats/config-lib-self-locating.bats +124 -0
  64. package/test/bats/inspector-post-write-hook.bats +92 -0
  65. package/test/bats/librarian-lesson-promote.bats +89 -3
  66. package/test/bats/validate-path.bats +46 -0
@@ -23,11 +23,68 @@ _inspector_sha256_first12() {
23
23
  fi
24
24
  }
25
25
 
26
+ # Resolve a path to its physical form — symlinks expanded, no trailing slash.
27
+ #
28
+ # The hook decides whether a touched file lives inside the repo by prefix-
29
+ # matching one canonicalized path against the other. Both sides MUST come
30
+ # through this one function. They used to be canonicalized independently
31
+ # (realpath for the file, `git rev-parse --show-toplevel` for the root), each
32
+ # with its own fallback, and on macOS /var is a symlink to /private/var — so
33
+ # whenever either mechanism fell back, the two sides landed in different
34
+ # namespaces and the prefix match failed. The hook then reported not_in_repo
35
+ # for a file plainly inside the repo, exiting 0 with no output. See
36
+ # ecosystem-foi, where that surfaced as an intermittent test failure.
37
+ #
38
+ # The last resort is `cd` + `pwd -P`, a bash builtin that needs no external
39
+ # tool, so this still returns a physical path when neither realpath nor a
40
+ # GNU-style `readlink -f` is available.
41
+ #
42
+ # Usage: canonical=$(inspector_canonical_path "$some_path")
43
+ inspector_canonical_path() {
44
+ local p="${1:-}"
45
+ [[ -z "$p" ]] && return 0
46
+
47
+ local out
48
+ if out=$(realpath "$p" 2>/dev/null) && [[ -n "$out" ]]; then
49
+ printf '%s' "$out"
50
+ return 0
51
+ fi
52
+ # BSD readlink has no -f, so this silently no-ops there and falls through.
53
+ if out=$(readlink -f "$p" 2>/dev/null) && [[ -n "$out" ]]; then
54
+ printf '%s' "$out"
55
+ return 0
56
+ fi
57
+
58
+ if [[ -d "$p" ]]; then
59
+ out=$(cd "$p" 2>/dev/null && pwd -P) && [[ -n "$out" ]] && {
60
+ printf '%s' "$out"
61
+ return 0
62
+ }
63
+ else
64
+ local dir base
65
+ dir=$(dirname "$p")
66
+ base=$(basename "$p")
67
+ out=$(cd "$dir" 2>/dev/null && pwd -P) && [[ -n "$out" ]] && {
68
+ printf '%s/%s' "$out" "$base"
69
+ return 0
70
+ }
71
+ fi
72
+
73
+ # Nothing resolved it — hand back the input rather than an empty string,
74
+ # so a caller comparing two of these still compares like with like.
75
+ printf '%s' "$p"
76
+ }
77
+
26
78
  inspector_project_repo_root() {
27
79
  local cwd="${1:-$(pwd)}"
28
80
  local root
29
- root=$(git -C "$cwd" rev-parse --show-toplevel 2>/dev/null) && printf '%s' "$root" && return 0
30
- printf '%s' "$cwd"
81
+ # Canonicalize BOTH the git answer and the fallback. git already returns a
82
+ # physical path, so the first call is a no-op; the fallback is the caller's
83
+ # raw cwd, which is exactly the case that used to diverge.
84
+ root=$(git -C "$cwd" rev-parse --show-toplevel 2>/dev/null) \
85
+ && [[ -n "$root" ]] \
86
+ && { inspector_canonical_path "$root"; return 0; }
87
+ inspector_canonical_path "$cwd"
31
88
  }
32
89
 
33
90
  inspector_project_remote_url() {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "librarian",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "Consolidation layer between archivist's per-session artifacts and the user's durable typed memory store. Detects which session decisions, dead-ends, and open questions deserve to live across sessions, classifies them into the user/feedback/project/reference types, and queues them as proposals for explicit confirmation. Auto-promotion is opt-in. Builds on the Onlooker ecosystem plugin.",
5
5
  "author": {
6
6
  "name": "Onlooker Community",
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.13.3](https://github.com/onlooker-community/ecosystem/compare/librarian-v0.13.2...librarian-v0.13.3) (2026-08-22)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **config:** let every config lib find the loader from its own path :broom: ([#198](https://github.com/onlooker-community/ecosystem/issues/198)) ([249fe41](https://github.com/onlooker-community/ecosystem/commit/249fe41bf191db48239c2028ba77a10b3dcb03af))
9
+ * **librarian:** key the declined-ledger guard on the proposal, not the artifact :bug: ([#199](https://github.com/onlooker-community/ecosystem/issues/199)) ([47a195d](https://github.com/onlooker-community/ecosystem/commit/47a195da98a3a565018c35e9e5c6dde2405520de))
10
+
3
11
  ## [0.13.2](https://github.com/onlooker-community/ecosystem/compare/librarian-v0.13.1...librarian-v0.13.2) (2026-08-18)
4
12
 
5
13
 
@@ -16,8 +16,12 @@
16
16
  # Settings overlay only touches the `librarian.*` subtree of settings.json so
17
17
  # it coexists with other plugins' configuration.
18
18
 
19
- # shellcheck source=../../../scripts/lib/config-loader.sh
20
- source "${PLUGIN_ROOT}/../../scripts/lib/config-loader.sh"
19
+ # Resolve the shared loader from this file's own location. $PLUGIN_ROOT is
20
+ # whatever the sourcing scope happened to set, so a sub-shell that inherits
21
+ # CLAUDE_PLUGIN_ROOT but not PLUGIN_ROOT would lose every accessor silently.
22
+ _LIBRARIAN_CONFIG_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
23
+ # shellcheck source=scripts/lib/config-loader.sh
24
+ source "${_LIBRARIAN_CONFIG_LIB_DIR}/../../../../scripts/lib/config-loader.sh"
21
25
 
22
26
  _LIBRARIAN_CONFIG="{}"
23
27
 
@@ -183,19 +183,39 @@ librarian_lesson_promote() {
183
183
  # declined.jsonl, double-counting a rejected artifact in the
184
184
  # rubric-tuning signal the ledger exists to carry.
185
185
  #
186
+ # Keyed on lesson_id, not artifact_id. The approved branch's guard is
187
+ # approved/<lesson_id>.json — per-proposal by construction — and this
188
+ # one has to match it. Keyed on artifact_id it could not tell "this
189
+ # artifact was already declined" from "a DIFFERENT proposal for the
190
+ # same artifact was already declined", so the second of two colliding
191
+ # proposals skipped its append and returned 0: both stamped, one
192
+ # verdict on disk. That is the inverse of the double-write this guard
193
+ # exists to stop, and still loses the per-judge detail (ecosystem-bkj).
194
+ #
195
+ # The artifact_id clause is the fallback for rows that legitimately
196
+ # carry no lesson_id: those written before this change, and those the
197
+ # transform writes for an artifact rejected before any proposal
198
+ # existed. Dropping it would leave an unstamped pre-change proposal
199
+ # double-writing on re-run — trading this bug for the older one.
200
+ #
186
201
  # Same scan shape as librarian_lesson_seen: -R/fromjson? survives a
187
202
  # truncated trailing line from a process killed mid-append, and
188
203
  # `objects` stops a valid-but-non-object line from erroring the whole
189
204
  # invocation.
190
205
  already_declined=false
191
206
  if [[ -f "$declined_path" ]] \
192
- && jq -Re --arg a "$artifact_id" 'fromjson? | objects | select(.artifact_id == $a)' \
207
+ && jq -Re --arg a "$artifact_id" --arg l "$lesson_id" \
208
+ 'fromjson? | objects
209
+ | select(
210
+ ($l != "" and .lesson_id == $l)
211
+ or ((.lesson_id // null) == null and .artifact_id == $a)
212
+ )' \
193
213
  "$declined_path" >/dev/null 2>&1; then
194
214
  already_declined=true
195
215
  fi
196
216
 
197
217
  if [[ "$already_declined" == false ]]; then
198
- librarian_lesson_append_declined "$key" "$artifact_id" "$reason" "" "$verdict" || {
218
+ librarian_lesson_append_declined "$key" "$artifact_id" "$reason" "" "$verdict" "$lesson_id" || {
199
219
  printf 'Lesson %s: cannot append to the declined ledger.\n' "$lesson_id" >&2
200
220
  return 1
201
221
  }
@@ -83,13 +83,27 @@ librarian_lesson_write_proposal() {
83
83
  # written by the transform have no verdict and simply lack the key — a format
84
84
  # failure has no jury.
85
85
  #
86
- # Usage: librarian_lesson_append_declined <key> <artifact_id> <reason> [detail] [verdict_json]
86
+ # `lesson_id` names the PROPOSAL this verdict came from, and is null when there
87
+ # is no proposal to name. The transform declines an artifact before any proposal
88
+ # exists (transform_invalid, schema_invalid, and friends), so its rows carry
89
+ # null here and are identified by artifact_id alone.
90
+ #
91
+ # It exists so promote's double-write guard can key on the proposal rather than
92
+ # the artifact. Keyed on artifact_id, that guard could not tell "this artifact
93
+ # was already declined" from "a DIFFERENT proposal for the same artifact was
94
+ # already declined", and silently dropped the second verdict — see
95
+ # ecosystem-bkj. Note this is the opposite of what librarian_lesson_seen wants:
96
+ # that function asks "was this ARTIFACT already handled?" and correctly stays
97
+ # keyed on artifact_id.
98
+ #
99
+ # Usage: librarian_lesson_append_declined <key> <artifact_id> <reason> [detail] [verdict_json] [lesson_id]
87
100
  librarian_lesson_append_declined() {
88
101
  local key="$1"
89
102
  local artifact_id="$2"
90
103
  local reason="$3"
91
104
  local detail="${4:-}"
92
105
  local verdict="${5:-}"
106
+ local lesson_id="${6:-}"
93
107
  [[ -z "$key" || -z "$artifact_id" || -z "$reason" ]] && return 1
94
108
 
95
109
  librarian_lesson_storage_init "$key" || return 1
@@ -99,12 +113,14 @@ librarian_lesson_append_declined() {
99
113
  if [[ -n "$verdict" ]]; then
100
114
  line=$(jq -cn \
101
115
  --arg artifact_id "$artifact_id" \
116
+ --arg lesson_id "$lesson_id" \
102
117
  --arg reason "$reason" \
103
118
  --arg detail "$detail" \
104
119
  --arg at "$now" \
105
120
  --argjson verdict "$verdict" \
106
121
  '{
107
122
  artifact_id: $artifact_id,
123
+ lesson_id: (if $lesson_id == "" then null else $lesson_id end),
108
124
  reason: $reason,
109
125
  detail: (if $detail == "" then null else $detail end),
110
126
  declined_at: $at,
@@ -113,11 +129,13 @@ librarian_lesson_append_declined() {
113
129
  else
114
130
  line=$(jq -cn \
115
131
  --arg artifact_id "$artifact_id" \
132
+ --arg lesson_id "$lesson_id" \
116
133
  --arg reason "$reason" \
117
134
  --arg detail "$detail" \
118
135
  --arg at "$now" \
119
136
  '{
120
137
  artifact_id: $artifact_id,
138
+ lesson_id: (if $lesson_id == "" then null else $lesson_id end),
121
139
  reason: $reason,
122
140
  detail: (if $detail == "" then null else $detail end),
123
141
  declined_at: $at
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lineage",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Per-change provenance for the Onlooker ecosystem. Records session/turn metadata plus a secret-redacted, size-capped snippet for every Edit/Write/MultiEdit at PostToolUse, then answers \"why does this line exist?\" via /lineage by joining change records to historian-preserved transcripts. Emits lineage.* events for audit. Builds on the Onlooker ecosystem plugin.",
5
5
  "author": {
6
6
  "name": "Onlooker Community",
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.3](https://github.com/onlooker-community/ecosystem/compare/lineage-v0.2.2...lineage-v0.2.3) (2026-08-22)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **config:** let every config lib find the loader from its own path :broom: ([#198](https://github.com/onlooker-community/ecosystem/issues/198)) ([249fe41](https://github.com/onlooker-community/ecosystem/commit/249fe41bf191db48239c2028ba77a10b3dcb03af))
9
+
3
10
  ## [0.2.2](https://github.com/onlooker-community/ecosystem/compare/lineage-v0.2.1...lineage-v0.2.2) (2026-08-02)
4
11
 
5
12
 
@@ -13,8 +13,12 @@
13
13
  # lineage_config_get <jq-path> # echoes string value (empty if unset)
14
14
  # lineage_config_get_json <jq-path> # echoes JSON value (null if unset)
15
15
 
16
- # shellcheck source=../../../scripts/lib/config-loader.sh
17
- source "${PLUGIN_ROOT}/../../scripts/lib/config-loader.sh"
16
+ # Resolve the shared loader from this file's own location. $PLUGIN_ROOT is
17
+ # whatever the sourcing scope happened to set, so a sub-shell that inherits
18
+ # CLAUDE_PLUGIN_ROOT but not PLUGIN_ROOT would lose every accessor silently.
19
+ _LINEAGE_CONFIG_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20
+ # shellcheck source=scripts/lib/config-loader.sh
21
+ source "${_LINEAGE_CONFIG_LIB_DIR}/../../../../scripts/lib/config-loader.sh"
18
22
 
19
23
  _lineage_CONFIG="{}"
20
24
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scribe",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Intent documentation from agent activity. Captures why changes were made — problem context, decisions, tradeoffs — and distills them into readable artifacts at session end.",
5
5
  "author": {
6
6
  "name": "Onlooker Community",
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.3](https://github.com/onlooker-community/ecosystem/compare/scribe-v0.4.2...scribe-v0.4.3) (2026-08-22)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **config:** let every config lib find the loader from its own path :broom: ([#198](https://github.com/onlooker-community/ecosystem/issues/198)) ([249fe41](https://github.com/onlooker-community/ecosystem/commit/249fe41bf191db48239c2028ba77a10b3dcb03af))
9
+
3
10
  ## [0.4.2](https://github.com/onlooker-community/ecosystem/compare/scribe-v0.4.1...scribe-v0.4.2) (2026-08-02)
4
11
 
5
12
 
@@ -13,8 +13,12 @@
13
13
  # scribe_config_get <jq-path> # echoes string value (empty if unset)
14
14
  # scribe_config_get_json <jq-path> # echoes JSON value (null if unset)
15
15
 
16
- # shellcheck source=../../../scripts/lib/config-loader.sh
17
- source "${PLUGIN_ROOT}/../../scripts/lib/config-loader.sh"
16
+ # Resolve the shared loader from this file's own location. $PLUGIN_ROOT is
17
+ # whatever the sourcing scope happened to set, so a sub-shell that inherits
18
+ # CLAUDE_PLUGIN_ROOT but not PLUGIN_ROOT would lose every accessor silently.
19
+ _SCRIBE_CONFIG_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20
+ # shellcheck source=scripts/lib/config-loader.sh
21
+ source "${_SCRIBE_CONFIG_LIB_DIR}/../../../../scripts/lib/config-loader.sh"
18
22
 
19
23
  _scribe_CONFIG="{}"
20
24
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tribunal",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "Multi-agent execution with LLM-as-a-Judge quality gates. An Actor performs work; a jury of typed Judges scores it against a project-overridable rubric; a Meta-Judge reviews the jury for bias; the gate decides accept, retry, or exhaust. Grounded in LLM-as-a-Judge (Zheng et al. 2023) and LLM-as-a-Meta-Judge (Wu et al. 2024). Builds on the Onlooker ecosystem plugin.",
5
5
  "author": {
6
6
  "name": "Onlooker Community",
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.8](https://github.com/onlooker-community/ecosystem/compare/tribunal-v1.2.7...tribunal-v1.2.8) (2026-08-22)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **config:** let every config lib find the loader from its own path :broom: ([#198](https://github.com/onlooker-community/ecosystem/issues/198)) ([249fe41](https://github.com/onlooker-community/ecosystem/commit/249fe41bf191db48239c2028ba77a10b3dcb03af))
9
+
3
10
  ## [1.2.7](https://github.com/onlooker-community/ecosystem/compare/tribunal-v1.2.6...tribunal-v1.2.7) (2026-08-16)
4
11
 
5
12
 
@@ -13,8 +13,12 @@
13
13
  # tribunal_config_get <jq-path> # echoes string value (empty if unset)
14
14
  # tribunal_config_get_json <jq-path> # echoes JSON value (null if unset)
15
15
 
16
- # shellcheck source=../../../scripts/lib/config-loader.sh
17
- source "${PLUGIN_ROOT}/../../scripts/lib/config-loader.sh"
16
+ # Resolve the shared loader from this file's own location. $PLUGIN_ROOT is
17
+ # whatever the sourcing scope happened to set, so a sub-shell that inherits
18
+ # CLAUDE_PLUGIN_ROOT but not PLUGIN_ROOT would lose every accessor silently.
19
+ _TRIBUNAL_CONFIG_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20
+ # shellcheck source=scripts/lib/config-loader.sh
21
+ source "${_TRIBUNAL_CONFIG_LIB_DIR}/../../../../scripts/lib/config-loader.sh"
18
22
 
19
23
  _TRIBUNAL_CONFIG="{}"
20
24
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warden",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Untrusted-content gate. Scans content flowing in through WebFetch and Read for prompt-injection patterns, and when a threat is detected closes a session-scoped gate that blocks Write, Edit, and Bash until the user explicitly clears it. Grounded in Meta's Agents Rule of Two: an agent should hold no more than two of {private data, external actions, untrusted content} at once — warden removes the external-actions property while untrusted content is in play. Builds on the Onlooker ecosystem plugin.",
5
5
  "author": {
6
6
  "name": "Onlooker Community",
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.2](https://github.com/onlooker-community/ecosystem/compare/warden-v0.3.1...warden-v0.3.2) (2026-08-22)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **config:** let every config lib find the loader from its own path :broom: ([#198](https://github.com/onlooker-community/ecosystem/issues/198)) ([249fe41](https://github.com/onlooker-community/ecosystem/commit/249fe41bf191db48239c2028ba77a10b3dcb03af))
9
+
3
10
  ## [0.3.1](https://github.com/onlooker-community/ecosystem/compare/warden-v0.3.0...warden-v0.3.1) (2026-08-01)
4
11
 
5
12
 
@@ -13,8 +13,12 @@
13
13
  # warden_config_get <jq-path> # echoes string value (empty if unset)
14
14
  # warden_config_get_json <jq-path> # echoes JSON value (null if unset)
15
15
 
16
- # shellcheck source=../../../scripts/lib/config-loader.sh
17
- source "${PLUGIN_ROOT}/../../scripts/lib/config-loader.sh"
16
+ # Resolve the shared loader from this file's own location. $PLUGIN_ROOT is
17
+ # whatever the sourcing scope happened to set, so a sub-shell that inherits
18
+ # CLAUDE_PLUGIN_ROOT but not PLUGIN_ROOT would lose every accessor silently.
19
+ _WARDEN_CONFIG_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20
+ # shellcheck source=scripts/lib/config-loader.sh
21
+ source "${_WARDEN_CONFIG_LIB_DIR}/../../../../scripts/lib/config-loader.sh"
18
22
 
19
23
  _warden_CONFIG="{}"
20
24
 
@@ -6,8 +6,21 @@
6
6
  # across the ecosystem.
7
7
  #
8
8
  # Usage:
9
- # # In your plugin's config loader (e.g., plugins/bursar/scripts/lib/bursar-config.sh):
10
- # source "${PLUGIN_ROOT}/../../scripts/lib/config-loader.sh"
9
+ # # In your plugin's config loader (e.g., plugins/bursar/scripts/lib/bursar-config.sh).
10
+ # # Locate this file from the sourcing file's OWN path, never from a
11
+ # # caller-supplied $PLUGIN_ROOT: that variable is read at source time from
12
+ # # whatever scope did the sourcing, so a sub-shell that inherits
13
+ # # CLAUDE_PLUGIN_ROOT but not PLUGIN_ROOT loses every accessor below while
14
+ # # still exiting 0 (see ecosystem-88v, ecosystem-7bj). Four levels up from
15
+ # # plugins/<name>/scripts/lib is the repo root.
16
+ # _BURSAR_CONFIG_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17
+ # # shellcheck source=scripts/lib/config-loader.sh
18
+ # source "${_BURSAR_CONFIG_LIB_DIR}/../../../../scripts/lib/config-loader.sh"
19
+ #
20
+ # The shellcheck directive is repo-root-relative, not file-relative: shellcheck
21
+ # resolves source= against its own working directory, and `npm run
22
+ # test:shellcheck` runs it from the repo root. A file-relative path there
23
+ # silently degrades to SC1091 "not following", which `-S error` hides.
11
24
  # config_load_plugin "bursar" "$repo_root" "_BURSAR_CONFIG"
12
25
  # config_get "_BURSAR_CONFIG" '.bursar.window' # returns value or empty string
13
26
  #
@@ -530,11 +530,32 @@ turn_state_next_tool() {
530
530
  fi
531
531
  }
532
532
 
533
- # Safely emit dev-os event (validates emit script exists)
534
- # Automatically exports turn state if not already set, so every emission
535
- # gets hook_type/turn/tool_call_seq in the envelope without callers needing
536
- # to call turn_state_export() explicitly.
537
- # Usage: echo "$INPUT" | safe_emit "event_type" '{"key":"value"}'
533
+ # Safely emit an Onlooker event through the canonical emitter.
534
+ #
535
+ # Automatically exports turn state if not already set, so a caller does not have
536
+ # to call turn_state_export() itself. Note the turn rides in the PAYLOAD, as
537
+ # turn_number, for the event types whose schema declares it — the envelope has
538
+ # no turn field and is additionalProperties:false.
539
+ #
540
+ # Returns non-zero and writes NOTHING when $ONLOOKER_EMIT is unavailable.
541
+ #
542
+ # There used to be a fallback here that hand-built an envelope with jq and
543
+ # appended it directly. Every line it wrote was unvalidatable: it omitted all
544
+ # five required id/schema_version/runtime/machine_id/sequence fields, and added
545
+ # four the envelope forbids outright (hook_type, tool_name, turn,
546
+ # tool_call_seq). It was reached only when $ONLOOKER_EMIT was missing — a file
547
+ # that ships next to this one, so it never fired in a normal checkout or
548
+ # install — which is how it stayed broken and unnoticed. See ecosystem-0tm.
549
+ #
550
+ # Dropping it rather than teaching it to call the emitter is the same
551
+ # fail-closed choice made for prompt_rules_emit in ecosystem-aaz: an
552
+ # unparseable line on the bus is worse than a missing one, and a second way to
553
+ # build an envelope is a second thing to drift.
554
+ #
555
+ # Callers must tolerate a non-zero return — hooks run under `set -e`, so use
556
+ # `safe_emit ... || true` when the emission is advisory.
557
+ #
558
+ # Usage: safe_emit "event_type" '{"key":"value"}'
538
559
  safe_emit() {
539
560
  local event_type="$1"
540
561
  local payload="$2"
@@ -544,38 +565,8 @@ safe_emit() {
544
565
  turn_state_export "$_HOOK_SESSION_ID"
545
566
  fi
546
567
 
547
- if validate_file_exists "$ONLOOKER_EMIT"; then
548
- "$ONLOOKER_EMIT" "$event_type" "$payload"
549
- else
550
- # Fallback: write directly to events log with envelope enrichment.
551
- # Uses env vars set by hook_set_context() — NOT stdin (already consumed).
552
- ensure_file_exists "$ONLOOKER_EVENTS_LOG" || return 1
553
- local timestamp session_id plugin_name hook_type tool_name turn tool_seq
554
- timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
555
- session_id="${_HOOK_SESSION_ID:-}"
556
- if [[ -z "$session_id" ]]; then
557
- session_id=$(echo "$payload" | jq -r '.session_id // "unknown"' 2>/dev/null) || session_id="unknown"
558
- fi
559
- plugin_name="${ONLOOKER_PLUGIN_NAME:-unknown}"
560
- hook_type="${ONLOOKER_HOOK_TYPE:-}"
561
- tool_name="${ONLOOKER_TOOL_NAME:-}"
562
- turn="${ONLOOKER_TURN_NUMBER:-}"
563
- tool_seq="${ONLOOKER_TURN_TOOL_SEQ:-}"
564
- jq -cn \
565
- --arg ts "$timestamp" \
566
- --arg sid "$session_id" \
567
- --arg plugin "$plugin_name" \
568
- --arg type "$event_type" \
569
- --arg hook_type "$hook_type" \
570
- --arg tool_name "$tool_name" \
571
- --arg turn "$turn" \
572
- --arg tool_seq "$tool_seq" \
573
- --argjson payload "$payload" \
574
- '{timestamp: $ts, session_id: $sid, plugin: $plugin, event_type: $type, payload: $payload}
575
- + (if $hook_type != "" then {hook_type: $hook_type} else {} end)
576
- + (if $tool_name != "" then {tool_name: $tool_name} else {} end)
577
- + (if $turn != "" then {turn: ($turn | tonumber)} else {} end)
578
- + (if $tool_seq != "" then {tool_call_seq: ($tool_seq | tonumber)} else {} end)
579
- ' >> "$ONLOOKER_EVENTS_LOG"
568
+ if ! validate_file_exists "$ONLOOKER_EMIT"; then
569
+ return 1
580
570
  fi
571
+ "$ONLOOKER_EMIT" "$event_type" "$payload"
581
572
  }
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env bats
2
+ #
3
+ # Guards that every plugin config lib locates config-loader.sh from its OWN
4
+ # path, not from a caller-supplied $PLUGIN_ROOT.
5
+ #
6
+ # These libs used to open with:
7
+ #
8
+ # source "${PLUGIN_ROOT}/../../scripts/lib/config-loader.sh"
9
+ #
10
+ # PLUGIN_ROOT is read at source time from whatever scope did the sourcing. From
11
+ # a scope that never set it, the path collapses to
12
+ # /../../scripts/lib/config-loader.sh, the source fails, and config_load_plugin
13
+ # and config_get never get defined. The caller then gets empty strings from
14
+ # every accessor while the script keeps going and exits 0 — the config silently
15
+ # falls back to defaults instead of failing loudly.
16
+ #
17
+ # Cartographer hit exactly this (ecosystem-88v): run-audit.sh and both hooks
18
+ # sourced the config lib inside `bash -c` sub-shells that inherited
19
+ # CLAUDE_PLUGIN_ROOT but not PLUGIN_ROOT. It went unnoticed for months because
20
+ # the analyzers take their settings as positional parameters and kept working.
21
+ #
22
+ # The sweep in ecosystem-7bj made every lib self-locating via BASH_SOURCE, which
23
+ # is correct regardless of caller scope, cwd, or sub-shell nesting. These tests
24
+ # cover all 16 at once so plugin 17 cannot quietly reintroduce the pattern.
25
+
26
+ setup() {
27
+ source "${BATS_TEST_DIRNAME}/../helpers/setup.bash"
28
+ setup_test_env
29
+ }
30
+
31
+ # Every plugins/<name>/scripts/lib/<name>-config.sh in the repo.
32
+ _config_libs() {
33
+ find "${REPO_ROOT}/plugins" -path '*/scripts/lib/*-config.sh' -type f | sort
34
+ }
35
+
36
+ # Without this, a typo in _config_libs would make every test below pass over an
37
+ # empty list and report coverage that does not exist. Not pinned to 16, so
38
+ # adding or removing a plugin does not fail it.
39
+ @test "the config-lib glob matches at least one file" {
40
+ local count
41
+ count=$(_config_libs | wc -l | tr -d ' ')
42
+ [ "$count" -gt 0 ]
43
+ }
44
+
45
+ @test "no config lib resolves config-loader.sh through \$PLUGIN_ROOT" {
46
+ local offenders=""
47
+ local lib
48
+ while IFS= read -r lib; do
49
+ if grep -q 'source "\${PLUGIN_ROOT}' "$lib"; then
50
+ offenders+="${lib#"${REPO_ROOT}/"}"$'\n'
51
+ fi
52
+ done < <(_config_libs)
53
+
54
+ [ -z "$offenders" ] || {
55
+ printf 'config libs still sourcing through $PLUGIN_ROOT:\n%s' "$offenders" >&2
56
+ return 1
57
+ }
58
+ }
59
+
60
+ @test "every config lib derives its own directory from BASH_SOURCE" {
61
+ local missing=""
62
+ local lib
63
+ while IFS= read -r lib; do
64
+ grep -q 'BASH_SOURCE\[0\]' "$lib" || missing+="${lib#"${REPO_ROOT}/"}"$'\n'
65
+ done < <(_config_libs)
66
+
67
+ [ -z "$missing" ] || {
68
+ printf 'config libs not self-locating via BASH_SOURCE:\n%s' "$missing" >&2
69
+ return 1
70
+ }
71
+ }
72
+
73
+ # The behavioral test the source-text guards above stand in for. Sources each
74
+ # lib in a sub-shell with PLUGIN_ROOT unset and asserts the shared accessors it
75
+ # depends on actually got defined.
76
+ @test "every config lib yields working accessors with PLUGIN_ROOT unset" {
77
+ local failures=""
78
+ local lib
79
+ while IFS= read -r lib; do
80
+ local plugin_dir plugin_name out
81
+ plugin_dir="${lib%/scripts/lib/*}"
82
+ plugin_name="$(basename "$plugin_dir")"
83
+
84
+ # CLAUDE_PLUGIN_ROOT is set because config_load_plugin genuinely needs it to
85
+ # find the plugin's own config.json; PLUGIN_ROOT is deliberately absent,
86
+ # which is the exact shape of the sub-shell that broke cartographer.
87
+ out=$(env -u PLUGIN_ROOT CLAUDE_PLUGIN_ROOT="$plugin_dir" HOME="$HOME" \
88
+ bash -c '
89
+ set -u
90
+ source "$1" 2>&1 || exit 1
91
+ type -t config_load_plugin >/dev/null 2>&1 || { echo "config_load_plugin undefined"; exit 1; }
92
+ type -t config_get >/dev/null 2>&1 || { echo "config_get undefined"; exit 1; }
93
+ config_load_plugin "$2" "" _PROBE || { echo "config_load_plugin failed"; exit 1; }
94
+ # A plugin ships a config.json, so the merged config must be a non-empty
95
+ # JSON object. "{}" here would mean the load degraded to defaults.
96
+ printf "%s" "$_PROBE" | jq -e "type == \"object\" and (length > 0)" >/dev/null \
97
+ || { echo "merged config empty: $_PROBE"; exit 1; }
98
+ ' _ "$lib" "$plugin_name" 2>&1) \
99
+ || failures+="${plugin_name}: ${out}"$'\n'
100
+ done < <(_config_libs)
101
+
102
+ [ -z "$failures" ] || {
103
+ printf 'config libs broken when PLUGIN_ROOT is unset:\n%s' "$failures" >&2
104
+ return 1
105
+ }
106
+ }
107
+
108
+ # Regression guard for the specific reported failure, kept separate so a break
109
+ # names cartographer directly rather than appearing in a list of 16.
110
+ @test "cartographer config survives the sub-shell shape that broke it" {
111
+ local plugin_dir="${REPO_ROOT}/plugins/cartographer"
112
+ run env -u PLUGIN_ROOT CLAUDE_PLUGIN_ROOT="$plugin_dir" bash -c '
113
+ source "'"${plugin_dir}"'/scripts/lib/cartographer-config.sh"
114
+ cartographer_config_load ""
115
+ cartographer_config_audit_interval_hours
116
+ '
117
+ [ "$status" -eq 0 ] || return 1
118
+ # The shipped default. Under the old pattern this came back empty, because
119
+ # the accessor was never defined and the failure was swallowed.
120
+ [[ -n "$output" ]] || return 1
121
+ [[ "$output" != *"No such file or directory"* ]] || return 1
122
+ [[ "$output" != *"command not found"* ]] || return 1
123
+ [ "$output" -eq "$output" ] 2>/dev/null
124
+ }