@onlooker-community/ecosystem 0.34.0 → 0.34.1

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 (45) hide show
  1. package/.claude/skills/writing-tests/SKILL.md +27 -0
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.release-please-manifest.json +6 -6
  4. package/AGENTS.md +111 -0
  5. package/CHANGELOG.md +7 -0
  6. package/package.json +1 -1
  7. package/plugins/assayer/.claude-plugin/plugin.json +1 -1
  8. package/plugins/assayer/CHANGELOG.md +7 -0
  9. package/plugins/assayer/scripts/lib/assayer-config.sh +6 -0
  10. package/plugins/curator/.claude-plugin/plugin.json +1 -1
  11. package/plugins/curator/CHANGELOG.md +7 -0
  12. package/plugins/curator/scripts/lib/curator-emit.sh +2 -1
  13. package/plugins/historian/.claude-plugin/plugin.json +1 -1
  14. package/plugins/historian/CHANGELOG.md +7 -0
  15. package/plugins/historian/scripts/lib/historian-emit.sh +2 -1
  16. package/plugins/librarian/.claude-plugin/plugin.json +1 -1
  17. package/plugins/librarian/CHANGELOG.md +7 -0
  18. package/plugins/librarian/scripts/lib/librarian-cli.sh +2 -1
  19. package/plugins/librarian/scripts/lib/librarian-emit.sh +2 -1
  20. package/plugins/tribunal/.claude-plugin/plugin.json +1 -1
  21. package/plugins/tribunal/CHANGELOG.md +7 -0
  22. package/plugins/tribunal/scripts/lib/tribunal-aggregate.sh +3 -1
  23. package/plugins/tribunal/scripts/lib/tribunal-gate.sh +2 -1
  24. package/scripts/lib/prompt-rules.sh +6 -1
  25. package/test/bats/archivist-inject.bats +1 -1
  26. package/test/bats/assayer-extract.bats +2 -2
  27. package/test/bats/bursar-session-start.bats +3 -3
  28. package/test/bats/cartographer-lock.bats +3 -3
  29. package/test/bats/compass-sanitizer.bats +11 -11
  30. package/test/bats/compass-transcript.bats +2 -2
  31. package/test/bats/config.bats +15 -15
  32. package/test/bats/curator-session-start.bats +10 -3
  33. package/test/bats/emit-payload-default.bats +52 -0
  34. package/test/bats/governor-ledger.bats +1 -1
  35. package/test/bats/historian-prompt-submit.bats +1 -1
  36. package/test/bats/inspector-post-write-hook.bats +4 -4
  37. package/test/bats/librarian-cli.bats +16 -16
  38. package/test/bats/librarian-session-start.bats +2 -2
  39. package/test/bats/lineage-config.bats +1 -1
  40. package/test/bats/lineage-redact.bats +5 -5
  41. package/test/bats/session-tracker.bats +4 -4
  42. package/test/bats/tribunal-jury.bats +1 -1
  43. package/test/bats/turn-tracker.bats +1 -1
  44. package/test/bats/warden-sanitizer.bats +3 -3
  45. package/test/bats/worktree-tracker.bats +2 -2
@@ -160,6 +160,33 @@ _seed_artifact() {
160
160
  }
161
161
  ```
162
162
 
163
+ ## Gate every assertion: non-final `[[ ]]` needs `|| return 1`
164
+
165
+ `bats` resolves `#!/usr/bin/env bash`, which on macOS is the system bash 3.2.
166
+ Under 3.2 a failing **non-final** `[[ ]]` does **not** fail the test body —
167
+ execution continues and the test reports `ok`. Single-bracket `[ ]`, failing
168
+ commands, and failing command substitutions all gate correctly even there; the
169
+ defect is specific to `[[ ]]`. Under bash 5.x (what CI runs) it gates properly,
170
+ so a broken assertion passes locally and only CI would catch it.
171
+
172
+ Only the **last** assertion in a test body is safe, because a body's exit
173
+ status is its last command. Any `[[ ]]` before that needs explicit gating:
174
+
175
+ ```bash
176
+ @test "example" {
177
+ [[ "$output" == *"expected"* ]] || return 1 # non-final — must gate
178
+ [ "$status" -eq 0 ] # final — gates on its own
179
+ }
180
+ ```
181
+
182
+ Do **not** "fix" this by swapping to `[ ]`. Most of these assertions rely on
183
+ `[[ ]]`-only behavior — `==` glob patterns, `=~` regex, internal `&&`/`||` —
184
+ and a blanket swap silently changes what they test.
185
+
186
+ When you add an assertion, break it on purpose once and confirm the test fails.
187
+ A test that passes whether or not the code is correct is worse than no test,
188
+ because it reports coverage that does not exist.
189
+
163
190
  ## Anti-patterns
164
191
 
165
192
  Don't hand-roll these — each has bitten the suite before:
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecosystem",
3
- "version": "0.34.0",
3
+ "version": "0.34.1",
4
4
  "description": "Observability substrate for Claude Code. Provides the shared $ONLOOKER_DIR storage root (default $HOME/.onlooker), canonical schema-validated event emission, session and tool tracking hooks, and prompt rules. Required by all other Onlooker plugins.",
5
5
  "author": {
6
6
  "name": "Onlooker Community",
@@ -1,7 +1,7 @@
1
1
  {
2
- ".": "0.34.0",
2
+ ".": "0.34.1",
3
3
  "plugins/archivist": "0.3.1",
4
- "plugins/tribunal": "1.1.2",
4
+ "plugins/tribunal": "1.1.3",
5
5
  "plugins/echo": "0.3.1",
6
6
  "plugins/cartographer": "0.3.1",
7
7
  "plugins/governor": "0.3.2",
@@ -9,10 +9,10 @@
9
9
  "plugins/scribe": "0.4.2",
10
10
  "plugins/counsel": "0.5.1",
11
11
  "plugins/warden": "0.3.1",
12
- "plugins/librarian": "0.7.0",
13
- "plugins/curator": "0.2.2",
14
- "plugins/historian": "0.3.2",
15
- "plugins/assayer": "1.1.2",
12
+ "plugins/librarian": "0.7.1",
13
+ "plugins/curator": "0.2.3",
14
+ "plugins/historian": "0.3.3",
15
+ "plugins/assayer": "1.1.3",
16
16
  "plugins/bursar": "0.3.0",
17
17
  "plugins/lineage": "0.2.2",
18
18
  "plugins/inspector": "0.3.2"
package/AGENTS.md CHANGED
@@ -47,6 +47,117 @@ cp -rf source dest # NOT: cp -r source dest
47
47
  - `apt-get` - use `-y` flag
48
48
  - `brew` - use `HOMEBREW_NO_AUTO_UPDATE=1` env var
49
49
 
50
+ <!-- The sections below are mirrored from CLAUDE.md. The two files are
51
+ independent — not symlinked, not sharing an inode — so an edit to the
52
+ repository's conventions must land in both or agents get different
53
+ instructions depending on which file their harness reads. Claude Code
54
+ reads CLAUDE.md; Codex and several other tools read this one. -->
55
+
56
+ ## Repository layout
57
+
58
+ ```
59
+ ecosystem/ ← substrate plugin (always-on observability)
60
+ hooks/ ← session, tool, and prompt hooks
61
+ scripts/lib/ ← shared bash helpers and the canonical event emitter
62
+ skills/ ← user-invocable slash commands
63
+ config.json ← ecosystem defaults
64
+
65
+ plugins/
66
+ archivist/ ← session memory across context truncation
67
+ bursar/ ← multi-session, per-project budget rollup (governor's cross-session view)
68
+ cartographer/ ← instruction-file auditor (CLAUDE.md, AGENTS.md, rules/)
69
+ compass/ ← pre-write alignment gate (design phase)
70
+ echo/ ← prompt-change regression detection
71
+ governor/ ← resource governance and budget enforcement
72
+ inspector/ ← per-edit lint and typecheck gate
73
+ lineage/ ← per-change provenance ("why does this line exist?")
74
+ tribunal/ ← multi-agent quality gate (Actor → Jury → Meta-Judge → Gate)
75
+
76
+ docs/
77
+ architecture.md ← how plugins compose and share the event bus
78
+ adr/ ← ecosystem-level architectural decisions
79
+
80
+ scripts/lib/onlooker-event.mjs ← canonical event builder; all plugins route through this
81
+ ~/.onlooker/ ← shared runtime storage (logs, plugin artifacts)
82
+ ```
83
+
84
+ ## Plugin map
85
+
86
+ | Plugin | Hook surface | When it fires |
87
+ |--------|-------------|---------------|
88
+ | ecosystem | SessionStart/End, PreToolUse, PostToolUse, PostToolUseFailure, UserPromptSubmit, UserPromptExpansion, PreCompact, PostCompact, TaskCreated, TaskCompleted, WorktreeCreate, WorktreeRemove | Always — substrate |
89
+ | archivist | PreCompact, SessionStart | Extracts decisions/dead-ends on compaction; reinjects at next SessionStart |
90
+ | cartographer | SessionStart, PostToolUse (Write, Edit, MultiEdit) | Audits instruction files on session start and after instruction-file writes |
91
+ | compass | PreToolUse (Write, Edit, MultiEdit, Bash) | Before any write — alignment check |
92
+ | echo | Stop | Regression-tests prompt changes after each agent stop |
93
+ | governor | SessionStart, PreToolUse (Task), PostToolUse (Task), Stop | Budget gates on subagent spawns; tracks spend per session |
94
+ | tribunal | Stop + skill invocation | Post-task quality gate; also invokable via `/tribunal` |
95
+ | warden | PostToolUse (WebFetch, Read), PreToolUse (Write, Edit, MultiEdit, Bash), SessionStart + skill invocation | Scans ingested content for injection; closes a content gate that blocks write-class tools until cleared via `/warden` |
96
+ | assayer | Stop | Verifies the agent's final-message claims against actual command results in the transcript; advisory |
97
+ | bursar | SessionStart, SessionEnd | Rolls each session's spend into a per-project ledger on SessionEnd; surfaces "this project burned $X this week" at SessionStart. Governor is per-session; bursar is the cross-session rollup |
98
+ | lineage | PostToolUse (Edit, Write, MultiEdit) + skill invocation | Records per-change provenance (session_id/turn + redacted, size-capped snippets) into a per-project ledger; `/lineage <file>:<line>` answers "why does this line exist?" by joining records to historian transcripts to recover prompt context |
99
+ | inspector | PostToolUse (Write, Edit, MultiEdit) | Per-edit verification: runs the project's configured lint + typecheck commands on just the touched file and emits `inspector.check.*` / `inspector.run.completed`. Surfaces issues to the agent for the next turn. Cheaper than the planned proctor (which runs the full project verify at Stop); complements assayer (which catches claims the agent makes without running anything) |
100
+
101
+ Plugins communicate by emitting events to the JSONL log — they do not call each other directly. All plugins depend on the ecosystem substrate; no plugin depends on another plugin directly.
102
+
103
+ ## Compass plugin (design phase)
104
+
105
+ Compass is the pre-write alignment gate. It has no implementation yet. Design lives in `plugins/compass/docs/design.md`.
106
+
107
+ **What it does:** Fires on `PreToolUse` for write-class tools. Samples N=5 parallel Haiku evaluators to score intent clarity. Blocks when `confidence < 0.65 OR stddev > 0.20` and surfaces a clarification prompt.
108
+
109
+ **Critical architectural decision (ADR-001):** The evaluator must see the **prior assistant turn** alongside the current context — not the current context alone. Evaluating a reply in isolation produces a systematic false-positive class: a user answering an agent's enumerated question ("the internal one") looks ambiguous without the question that prompted it.
110
+
111
+ The pipeline is:
112
+
113
+ ```
114
+ Trigger Gate → Transcript Reader → Symbolic Skip Layer → Sanitizer → N=5 Evaluators → Gate
115
+ ```
116
+
117
+ - **Transcript reader** resolves `prior_assistant_turn` from `transcript_path` in the hook JSON payload (same field tribunal-stop-gate.sh reads). Reads one turn back from that file (already committed before `PreToolUse` fires — no timing-skew risk). If `transcript_path` is absent or unreadable, proceeds with an empty prior turn.
118
+ - **Symbolic skip layer** short-circuits to `confident` when the prior turn is an enumerated question and the current context is an option reference, without an LLM call. Controlled by `skip_patterns.reply_to_question.enabled` (default `true`).
119
+ - **Evaluator prompt** uses a structured pair: `<prior_assistant_turn>` and `<context_excerpt>` as separate XML-delimited slots. The convergence question is: *"Given the prior assistant turn as context, would two independent readers converge on the same interpretation of this write?"*
120
+
121
+ See `plugins/compass/docs/adr/001-evaluate-prompts-in-context.md` for the full decision record.
122
+
123
+ ## Adding a new plugin
124
+
125
+ 1. Create `plugins/<name>/` with `.claude-plugin/plugin.json`, `config.json`, `hooks/hooks.json`.
126
+ 2. Use `scripts/lib/onlooker-event.mjs` for all event emission — never write directly to the JSONL log.
127
+ 3. Store runtime artifacts under `${ONLOOKER_DIR:-$HOME/.onlooker}/<name>/<project-key>/`. Always use `$ONLOOKER_DIR` — never hardcode `~/.onlooker` — so the test suite's isolated temp home is respected.
128
+ 4. Derive the project key via `tribunal_project_key` (or equivalent) — first 12 hex chars of SHA256(`remote:<origin-url>`), falling back to SHA256(`root:<repo-root>`) for repos without a remote. See `plugins/tribunal/scripts/lib/tribunal-project-key.sh`.
129
+ 5. Register event types in `@onlooker-community/schema` before emitting them. The runtime emitter is dependency-free and **fails open**: it validates against the schema package only when that package is resolvable (dev, CI, tests) and emits unconditionally otherwise, because installed marketplace plugins ship no `node_modules`. Schema drift is caught in CI against the published schemas at `schema.onlooker.dev`. See [ADR-005](docs/adr/005-runtime-emitter-fails-open.md).
130
+ 6. Fail-soft when `~/.onlooker/` is absent — plugins must not block a session they were not invited to.
131
+
132
+ ## Development
133
+
134
+ ```bash
135
+ mise install # installs all tools declared in mise.toml
136
+ npm ci
137
+ npm test # bats + schema validation
138
+ npm run test:ci # shellcheck + bats + schema + lint
139
+ ```
140
+
141
+ Tests use an isolated temp home; nothing writes to your real `~/.onlooker/`.
142
+
143
+ ## Git workflow
144
+
145
+ **Always open a PR — never push directly to `main`.** Even though bypass rights allow direct pushes, this repo uses release-please for automated changelogs and versioning, so every change must travel through a PR to be picked up correctly. CI also runs on PRs before merge, catching failures before they land.
146
+
147
+ Workflow:
148
+ 1. Create a feature branch: `git switch -c <type>/<short-description>`
149
+ 2. Commit using `/commit`
150
+ 3. Push the branch and open a PR using `/git-workflow:pr`
151
+ 4. Wait for CI to pass before merging
152
+
153
+ ## Conventions
154
+
155
+ - All hooks are bash scripts. No Python, no Node entry points in hook scripts (they may shell out to `node` for event emission or heavy lifting).
156
+ - Hook scripts source shared helpers from `scripts/lib/` (or the plugin's own `scripts/lib/`).
157
+ - Event types follow `<plugin>.<noun>.<verb>` — e.g. `compass.check.skipped`, `tribunal.gate.blocked`.
158
+ - ULIDs everywhere for IDs (not UUIDs). Each plugin ships its own `*_ulid` helper (e.g. `archivist-ulid.sh`, `tribunal-ulid.sh`); there is no shared ecosystem helper. Copy `plugins/tribunal/scripts/lib/tribunal-ulid.sh` as a starting point and rename the function prefix.
159
+ - Config defaults live in `config.json`. User overrides go in `~/.claude/settings.json` (global) or `.claude/settings.json` (per-project) under the plugin's namespace key (e.g. `"compass"`, `"tribunal"`). See ADR-004.
160
+
50
161
  <!-- BEGIN BEADS INTEGRATION v:1 profile:minimal hash:970c3bf2 -->
51
162
  ## Beads Issue Tracker
52
163
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.34.1](https://github.com/onlooker-community/ecosystem/compare/ecosystem-v0.34.0...ecosystem-v0.34.1) (2026-08-10)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * make the local bats suite tell the truth :mag: ([#135](https://github.com/onlooker-community/ecosystem/issues/135)) ([f0763e0](https://github.com/onlooker-community/ecosystem/commit/f0763e09f3caf2d39c89f28befd12567af0af845))
9
+
3
10
  ## [0.34.0](https://github.com/onlooker-community/ecosystem/compare/ecosystem-v0.33.1...ecosystem-v0.34.0) (2026-08-09)
4
11
 
5
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlooker-community/ecosystem",
3
- "version": "0.34.0",
3
+ "version": "0.34.1",
4
4
  "description": "Agents, skills, hooks, commands, rules, and MCP configurations that power [Onlooker](https://onlooker.dev)",
5
5
  "author": {
6
6
  "name": "Onlooker Community",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assayer",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Claim verification. At session end, parses the agent's final message for testable claims (\"I ran the tests, they pass\", \"the build is green\") and checks each against the actual command results in the session transcript, classifying it corroborated, contradicted, or unverifiable. Catches lying-without-malice. Advisory by default. 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.1.3](https://github.com/onlooker-community/ecosystem/compare/assayer-v1.1.2...assayer-v1.1.3) (2026-08-10)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * make the local bats suite tell the truth :mag: ([#135](https://github.com/onlooker-community/ecosystem/issues/135)) ([f0763e0](https://github.com/onlooker-community/ecosystem/commit/f0763e09f3caf2d39c89f28befd12567af0af845))
9
+
3
10
  ## [1.1.2](https://github.com/onlooker-community/ecosystem/compare/assayer-v1.1.1...assayer-v1.1.2) (2026-08-02)
4
11
 
5
12
 
@@ -57,3 +57,9 @@ assayer_config_timeout() {
57
57
  v=$(assayer_config_get '.assayer.evaluation.timeout_seconds')
58
58
  printf '%s' "${v:-60}"
59
59
  }
60
+
61
+ assayer_config_final_message_chars() {
62
+ local v
63
+ v=$(assayer_config_get '.assayer.final_message_chars')
64
+ printf '%s' "${v:-6000}"
65
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "curator",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Maintenance layer for the user's typed auto-memory store. At every SessionStart, runs four cheap heuristic checks (date_decayed, path_broken, broken_index, orphaned_memory) against the memories at ~/.claude/projects/<encoded>/memory/ inside a wall-clock budget. Surfaces findings as a one-line pointer to /curator review; never edits the memory store directly. 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/curator-v0.2.2...curator-v0.2.3) (2026-08-10)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * make the local bats suite tell the truth :mag: ([#135](https://github.com/onlooker-community/ecosystem/issues/135)) ([f0763e0](https://github.com/onlooker-community/ecosystem/commit/f0763e09f3caf2d39c89f28befd12567af0af845))
9
+
3
10
  ## [0.2.2](https://github.com/onlooker-community/ecosystem/compare/curator-v0.2.1...curator-v0.2.2) (2026-08-02)
4
11
 
5
12
 
@@ -39,7 +39,8 @@ _CURATOR_EVENT_JS="${_CURATOR_EVENT_JS:-$(_curator_resolve_event_js)}"
39
39
  curator_emit() {
40
40
  local event_type="${1:-}"
41
41
  local session_id="${2:-}"
42
- local payload="${3:-{\}}"
42
+ local payload="${3:-}"
43
+ [ -z "$payload" ] && payload='{}'
43
44
 
44
45
  [[ -z "$event_type" || -z "$session_id" ]] && return 0
45
46
  [[ -z "$_CURATOR_EVENT_JS" || ! -f "$_CURATOR_EVENT_JS" ]] && return 0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "historian",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Episodic memory layer. At SessionEnd, chunks and sanitizes the session transcript and stores chunks under $ONLOOKER_DIR/historian/<project-key>/sessions/ (default $HOME/.onlooker). On UserPromptSubmit, embeds the prompt and performs similarity retrieval over stored chunks to surface relevant past context. 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.3](https://github.com/onlooker-community/ecosystem/compare/historian-v0.3.2...historian-v0.3.3) (2026-08-10)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * make the local bats suite tell the truth :mag: ([#135](https://github.com/onlooker-community/ecosystem/issues/135)) ([f0763e0](https://github.com/onlooker-community/ecosystem/commit/f0763e09f3caf2d39c89f28befd12567af0af845))
9
+
3
10
  ## [0.3.2](https://github.com/onlooker-community/ecosystem/compare/historian-v0.3.1...historian-v0.3.2) (2026-08-01)
4
11
 
5
12
 
@@ -39,7 +39,8 @@ _HISTORIAN_EVENT_JS="${_HISTORIAN_EVENT_JS:-$(_historian_resolve_event_js)}"
39
39
  historian_emit() {
40
40
  local event_type="${1:-}"
41
41
  local session_id="${2:-}"
42
- local payload="${3:-{\}}"
42
+ local payload="${3:-}"
43
+ [ -z "$payload" ] && payload='{}'
43
44
 
44
45
  [[ -z "$event_type" || -z "$session_id" ]] && return 0
45
46
  [[ -z "$_HISTORIAN_EVENT_JS" || ! -f "$_HISTORIAN_EVENT_JS" ]] && return 0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "librarian",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.7.1](https://github.com/onlooker-community/ecosystem/compare/librarian-v0.7.0...librarian-v0.7.1) (2026-08-10)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * make the local bats suite tell the truth :mag: ([#135](https://github.com/onlooker-community/ecosystem/issues/135)) ([f0763e0](https://github.com/onlooker-community/ecosystem/commit/f0763e09f3caf2d39c89f28befd12567af0af845))
9
+
3
10
  ## [0.7.0](https://github.com/onlooker-community/ecosystem/compare/librarian-v0.6.1...librarian-v0.7.0) (2026-08-09)
4
11
 
5
12
 
@@ -117,7 +117,8 @@ _librarian_cli_set_proposal_status() {
117
117
  local key="$1"
118
118
  local proposal_id="$2"
119
119
  local new_status="$3"
120
- local extra_json="${4:-{\}}"
120
+ local extra_json="${4:-}"
121
+ [ -z "$extra_json" ] && extra_json='{}'
121
122
  [[ -z "$key" || -z "$proposal_id" || -z "$new_status" ]] && return 1
122
123
 
123
124
  local path
@@ -50,7 +50,8 @@ _LIBRARIAN_EVENT_JS="${_LIBRARIAN_EVENT_JS:-$(_librarian_resolve_event_js)}"
50
50
  librarian_emit() {
51
51
  local event_type="${1:-}"
52
52
  local session_id="${2:-}"
53
- local payload="${3:-{\}}"
53
+ local payload="${3:-}"
54
+ [ -z "$payload" ] && payload='{}'
54
55
 
55
56
  [[ -z "$event_type" || -z "$session_id" ]] && return 0
56
57
  [[ -z "$_LIBRARIAN_EVENT_JS" || ! -f "$_LIBRARIAN_EVENT_JS" ]] && return 0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tribunal",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
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.1.3](https://github.com/onlooker-community/ecosystem/compare/tribunal-v1.1.2...tribunal-v1.1.3) (2026-08-10)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * make the local bats suite tell the truth :mag: ([#135](https://github.com/onlooker-community/ecosystem/issues/135)) ([f0763e0](https://github.com/onlooker-community/ecosystem/commit/f0763e09f3caf2d39c89f28befd12567af0af845))
9
+
3
10
  ## [1.1.2](https://github.com/onlooker-community/ecosystem/compare/tribunal-v1.1.1...tribunal-v1.1.2) (2026-08-02)
4
11
 
5
12
 
@@ -25,7 +25,9 @@
25
25
  tribunal_aggregate() {
26
26
  local method="${1:-mean}"
27
27
  local verdicts="${2:-[]}"
28
- local _rubric="${3:-{}}" # reserved for true weighted_mean once per-criterion scores are threaded
28
+ # reserved for true weighted_mean once per-criterion scores are threaded
29
+ local _rubric="${3:-}"
30
+ [ -z "$_rubric" ] && _rubric='{}'
29
31
  : "$_rubric"
30
32
 
31
33
  local count
@@ -23,7 +23,8 @@ tribunal_gate_decide() {
23
23
  local verdicts="${2:-[]}"
24
24
  local aggregated_score="${3:-0}"
25
25
  local score_threshold="${4:-0.75}"
26
- local meta="${5:-{}}"
26
+ local meta="${5:-}"
27
+ [ -z "$meta" ] && meta='{}'
27
28
  local dissent_score="${6:-0}"
28
29
  local dissent_threshold="${7:-0.25}"
29
30
 
@@ -148,7 +148,12 @@ prompt_rules_pattern_matches() {
148
148
  prompt_rules_emit() {
149
149
  local session_id="${1:-unknown}"
150
150
  local event_type="${2:-}"
151
- local payload_json="${3:-{\}}"
151
+ # Default the payload without inlining braces in the expansion. Both
152
+ # `${3:-{\}}` and `${3:-{}}` are wrong: the first keeps the backslash on
153
+ # bash 3.2 (macOS system bash), and the second appends a stray `}` to any
154
+ # payload that IS supplied, on every bash version.
155
+ local payload_json="${3:-}"
156
+ [ -z "$payload_json" ] && payload_json='{}'
152
157
  [[ -z "$event_type" ]] && return 1
153
158
  ensure_file_exists "$ONLOOKER_EVENTS_LOG" || return 1
154
159
 
@@ -46,7 +46,7 @@ setup() {
46
46
  echo "$output" | jq -e '.hookSpecificOutput.hookEventName == "SessionStart"' >/dev/null
47
47
  local ctx
48
48
  ctx=$(echo "$output" | jq -r '.hookSpecificOutput.additionalContext')
49
- [[ "$ctx" == *"use git remote SHA256 as project key"* ]]
49
+ [[ "$ctx" == *"use git remote SHA256 as project key"* ]] || return 1
50
50
  [[ "$ctx" == *"Archivist injected 1"* ]]
51
51
  }
52
52
 
@@ -70,7 +70,7 @@ setup() {
70
70
  @test "extraction prompt includes the message and the JSON contract" {
71
71
  run assayer_build_extraction_prompt "I ran the tests and they pass." 5
72
72
  [ "$status" -eq 0 ]
73
- [[ "$output" == *"I ran the tests and they pass."* ]]
74
- [[ "$output" == *"TESTABLE SUCCESS CLAIM"* ]]
73
+ [[ "$output" == *"I ran the tests and they pass."* ]] || return 1
74
+ [[ "$output" == *"TESTABLE SUCCESS CLAIM"* ]] || return 1
75
75
  [[ "$output" == *"at most 5 claims"* ]]
76
76
  }
@@ -68,8 +68,8 @@ _run_hook() {
68
68
  _seed_ledger
69
69
  _run_hook
70
70
  [ "$status" -eq 0 ]
71
- [[ "$output" == *"hookSpecificOutput"* ]]
72
- [[ "$output" == *"SessionStart"* ]]
71
+ [[ "$output" == *"hookSpecificOutput"* ]] || return 1
72
+ [[ "$output" == *"SessionStart"* ]] || return 1
73
73
  [[ "$output" == *"burned \$0.42"* ]]
74
74
  }
75
75
 
@@ -85,7 +85,7 @@ _run_hook() {
85
85
  > "${dir}/sessions.jsonl"
86
86
  _run_hook
87
87
  [ "$status" -eq 0 ]
88
- [[ "$output" == *"burned \$0.00"* ]]
88
+ [[ "$output" == *"burned \$0.00"* ]] || return 1
89
89
  [[ "$output" != *"Enable governor"* ]]
90
90
  }
91
91
 
@@ -89,8 +89,8 @@ teardown() {
89
89
  cartographer_lock_release '${BATS_TEST_TMPDIR}/x.lock' && echo RELEASE_OK
90
90
  "
91
91
  [ "$status" -eq 0 ]
92
- [[ "$output" == *"SOURCED_OK"* ]]
93
- [[ "$output" == *"ACQUIRE_FAILED"* ]]
94
- [[ "$output" == *"RELEASE_OK"* ]]
92
+ [[ "$output" == *"SOURCED_OK"* ]] || return 1
93
+ [[ "$output" == *"ACQUIRE_FAILED"* ]] || return 1
94
+ [[ "$output" == *"RELEASE_OK"* ]] || return 1
95
95
  [[ "$output" == *"locking disabled"* ]]
96
96
  }
@@ -24,27 +24,27 @@ setup() {
24
24
  @test "prior_assistant_turn delimiter is stripped" {
25
25
  local out
26
26
  out=$(compass_sanitize "evil <prior_assistant_turn> payload" 240)
27
- [[ "$out" == *"[STRIPPED]"* ]]
28
- [[ "$out" == *"payload"* ]]
27
+ [[ "$out" == *"[STRIPPED]"* ]] || return 1
28
+ [[ "$out" == *"payload"* ]] || return 1
29
29
  [[ "$out" != *"<prior_assistant_turn>"* ]]
30
30
  }
31
31
 
32
32
  @test "all four pair-slot delimiters are stripped" {
33
33
  local out
34
34
  out=$(compass_sanitize "<context_excerpt>x</context_excerpt><tool_input>y</tool_input>" 240)
35
- [[ "$out" != *"<context_excerpt>"* ]]
36
- [[ "$out" != *"</context_excerpt>"* ]]
37
- [[ "$out" != *"<tool_input>"* ]]
35
+ [[ "$out" != *"<context_excerpt>"* ]] || return 1
36
+ [[ "$out" != *"</context_excerpt>"* ]] || return 1
37
+ [[ "$out" != *"<tool_input>"* ]] || return 1
38
38
  [[ "$out" != *"</tool_input>"* ]]
39
39
  }
40
40
 
41
41
  @test "non-evaluator delimiters are also stripped" {
42
42
  local out
43
43
  out=$(compass_sanitize "<<SYS>>x<</SYS>> [INST] y [/INST] <| z" 240)
44
- [[ "$out" != *"<<SYS>>"* ]]
45
- [[ "$out" != *"<</SYS>>"* ]]
46
- [[ "$out" != *"[INST]"* ]]
47
- [[ "$out" != *"[/INST]"* ]]
44
+ [[ "$out" != *"<<SYS>>"* ]] || return 1
45
+ [[ "$out" != *"<</SYS>>"* ]] || return 1
46
+ [[ "$out" != *"[INST]"* ]] || return 1
47
+ [[ "$out" != *"[/INST]"* ]] || return 1
48
48
  [[ "$out" != *"<|"* ]]
49
49
  }
50
50
 
@@ -53,8 +53,8 @@ setup() {
53
53
  input=$(printf 'a\tb\nc\x00d\x01e')
54
54
  local out
55
55
  out=$(compass_sanitize "$input" 240)
56
- [[ "$out" == *"a"* && "$out" == *"b"* && "$out" == *"c"* ]]
57
- [[ "$out" == *"d"* && "$out" == *"e"* ]]
56
+ [[ "$out" == *"a"* && "$out" == *"b"* && "$out" == *"c"* ]] || return 1
57
+ [[ "$out" == *"d"* && "$out" == *"e"* ]] || return 1
58
58
  [ "${out}" = "$(printf 'a\tb\ncde')" ]
59
59
  }
60
60
 
@@ -60,8 +60,8 @@ setup() {
60
60
  EOF
61
61
  local out
62
62
  out=$(compass_read_prior_turn "$t" 800)
63
- [[ "$out" == *"[STRIPPED]"* ]]
64
- [[ "$out" != *"<prior_assistant_turn>"* ]]
63
+ [[ "$out" == *"[STRIPPED]"* ]] || return 1
64
+ [[ "$out" != *"<prior_assistant_turn>"* ]] || return 1
65
65
 
66
66
  # Truncation honors max_chars.
67
67
  local short
@@ -27,7 +27,7 @@ setup_file() {
27
27
 
28
28
  local hook_cmd
29
29
  hook_cmd=$(jq -r '.hooks.PreToolUse[0].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
30
- [[ "$hook_cmd" == *tool-sequence-tracker.sh ]]
30
+ [[ "$hook_cmd" == *tool-sequence-tracker.sh ]] || return 1
31
31
 
32
32
  local script_path="${hook_cmd//\$CLAUDE_PLUGIN_ROOT/$REPO_ROOT}"
33
33
  script_path="${script_path//\"/}"
@@ -41,7 +41,7 @@ setup_file() {
41
41
 
42
42
  local hook_cmd
43
43
  hook_cmd=$(jq -r '.hooks.PreToolUse[1].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
44
- [[ "$hook_cmd" == *agent-spawn-tracker.sh ]]
44
+ [[ "$hook_cmd" == *agent-spawn-tracker.sh ]] || return 1
45
45
 
46
46
  local script_path="${hook_cmd//\$CLAUDE_PLUGIN_ROOT/$REPO_ROOT}"
47
47
  script_path="${script_path//\"/}"
@@ -55,7 +55,7 @@ setup_file() {
55
55
 
56
56
  local hook_cmd
57
57
  hook_cmd=$(jq -r '.hooks.PreToolUse[2].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
58
- [[ "$hook_cmd" == *skill-usage-tracker.sh ]]
58
+ [[ "$hook_cmd" == *skill-usage-tracker.sh ]] || return 1
59
59
 
60
60
  local script_path="${hook_cmd//\$CLAUDE_PLUGIN_ROOT/$REPO_ROOT}"
61
61
  script_path="${script_path//\"/}"
@@ -78,7 +78,7 @@ setup_file() {
78
78
 
79
79
  local hook_cmd
80
80
  hook_cmd=$(jq -r '.hooks.PostToolUse[0].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
81
- [[ "$hook_cmd" == *tool-history-tracker.sh ]]
81
+ [[ "$hook_cmd" == *tool-history-tracker.sh ]] || return 1
82
82
 
83
83
  local script_path="${hook_cmd//\$CLAUDE_PLUGIN_ROOT/$REPO_ROOT}"
84
84
  script_path="${script_path//\"/}"
@@ -103,9 +103,9 @@ setup_file() {
103
103
  turn_cmd=$(jq -r '.hooks.UserPromptSubmit[0].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
104
104
  duration_cmd=$(jq -r '.hooks.UserPromptSubmit[0].hooks[1].command' "${REPO_ROOT}/hooks/hooks.json")
105
105
  rule_cmd=$(jq -r '.hooks.UserPromptSubmit[0].hooks[2].command' "${REPO_ROOT}/hooks/hooks.json")
106
- [[ "$turn_cmd" == *turn-tracker.sh ]]
107
- [[ "$duration_cmd" == *session-duration-tracker.sh ]]
108
- [[ "$rule_cmd" == *prompt-rule-injector.sh ]]
106
+ [[ "$turn_cmd" == *turn-tracker.sh ]] || return 1
107
+ [[ "$duration_cmd" == *session-duration-tracker.sh ]] || return 1
108
+ [[ "$rule_cmd" == *prompt-rule-injector.sh ]] || return 1
109
109
 
110
110
  for hook_cmd in "$turn_cmd" "$duration_cmd" "$rule_cmd"; do
111
111
  local script_path="${hook_cmd//\$CLAUDE_PLUGIN_ROOT/$REPO_ROOT}"
@@ -121,7 +121,7 @@ setup_file() {
121
121
 
122
122
  local hook_cmd
123
123
  hook_cmd=$(jq -r '.hooks.SessionStart[0].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
124
- [[ "$hook_cmd" == *session-start-tracker.sh ]]
124
+ [[ "$hook_cmd" == *session-start-tracker.sh ]] || return 1
125
125
 
126
126
  local script_path="${hook_cmd//\$CLAUDE_PLUGIN_ROOT/$REPO_ROOT}"
127
127
  script_path="${script_path//\"/}"
@@ -135,7 +135,7 @@ setup_file() {
135
135
 
136
136
  local hook_cmd
137
137
  hook_cmd=$(jq -r '.hooks.PreCompact[0].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
138
- [[ "$hook_cmd" == *pre-compact-tracker.sh ]]
138
+ [[ "$hook_cmd" == *pre-compact-tracker.sh ]] || return 1
139
139
 
140
140
  run jq -e '.hooks.PreCompact[0].matcher == "manual" and .hooks.PreCompact[1].matcher == "auto"' \
141
141
  "${REPO_ROOT}/hooks/hooks.json"
@@ -153,7 +153,7 @@ setup_file() {
153
153
 
154
154
  local hook_cmd
155
155
  hook_cmd=$(jq -r '.hooks.PostCompact[0].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
156
- [[ "$hook_cmd" == *context-compact-tracker.sh ]]
156
+ [[ "$hook_cmd" == *context-compact-tracker.sh ]] || return 1
157
157
 
158
158
  local script_path="${hook_cmd//\$CLAUDE_PLUGIN_ROOT/$REPO_ROOT}"
159
159
  script_path="${script_path//\"/}"
@@ -167,7 +167,7 @@ setup_file() {
167
167
 
168
168
  local hook_cmd
169
169
  hook_cmd=$(jq -r '.hooks.SessionEnd[0].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
170
- [[ "$hook_cmd" == *session-end-tracker.sh ]]
170
+ [[ "$hook_cmd" == *session-end-tracker.sh ]] || return 1
171
171
 
172
172
  local script_path="${hook_cmd//\$CLAUDE_PLUGIN_ROOT/$REPO_ROOT}"
173
173
  script_path="${script_path//\"/}"
@@ -178,7 +178,7 @@ setup_file() {
178
178
  @test "hooks.json TaskCreated references task-tracker" {
179
179
  local hook_cmd
180
180
  hook_cmd=$(jq -r '.hooks.TaskCreated[0].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
181
- [[ "$hook_cmd" == *task-tracker.sh ]]
181
+ [[ "$hook_cmd" == *task-tracker.sh ]] || return 1
182
182
 
183
183
  local script_path="${hook_cmd//\$CLAUDE_PLUGIN_ROOT/$REPO_ROOT}"
184
184
  script_path="${script_path//\"/}"
@@ -189,7 +189,7 @@ setup_file() {
189
189
  @test "hooks.json TaskCompleted references task-tracker" {
190
190
  local hook_cmd
191
191
  hook_cmd=$(jq -r '.hooks.TaskCompleted[0].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
192
- [[ "$hook_cmd" == *task-tracker.sh ]]
192
+ [[ "$hook_cmd" == *task-tracker.sh ]] || return 1
193
193
 
194
194
  local script_path="${hook_cmd//\$CLAUDE_PLUGIN_ROOT/$REPO_ROOT}"
195
195
  script_path="${script_path//\"/}"
@@ -200,7 +200,7 @@ setup_file() {
200
200
  @test "hooks.json WorktreeCreate references worktree-tracker" {
201
201
  local hook_cmd
202
202
  hook_cmd=$(jq -r '.hooks.WorktreeCreate[0].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
203
- [[ "$hook_cmd" == *worktree-tracker.sh ]]
203
+ [[ "$hook_cmd" == *worktree-tracker.sh ]] || return 1
204
204
 
205
205
  local script_path="${hook_cmd//\$CLAUDE_PLUGIN_ROOT/$REPO_ROOT}"
206
206
  script_path="${script_path//\"/}"
@@ -211,7 +211,7 @@ setup_file() {
211
211
  @test "hooks.json WorktreeRemove references worktree-tracker" {
212
212
  local hook_cmd
213
213
  hook_cmd=$(jq -r '.hooks.WorktreeRemove[0].hooks[0].command' "${REPO_ROOT}/hooks/hooks.json")
214
- [[ "$hook_cmd" == *worktree-tracker.sh ]]
214
+ [[ "$hook_cmd" == *worktree-tracker.sh ]] || return 1
215
215
 
216
216
  local script_path="${hook_cmd//\$CLAUDE_PLUGIN_ROOT/$REPO_ROOT}"
217
217
  script_path="${script_path//\"/}"
@@ -35,10 +35,17 @@ setup() {
35
35
  # project settings file.
36
36
  MEM_DIR="${TEST_HOME}/.claude/projects/test-project/memory"
37
37
  mkdir -p "$MEM_DIR" "${PROJECT_REPO}/.claude"
38
+ # Pin a generous wall-clock budget. The hook checks
39
+ # cheap_checks.wall_clock_budget_ms before EACH phase and skips the rest
40
+ # once it trips, so at the shipped default of 500ms a loaded machine can
41
+ # blow the budget before the later phases run — the orphan check among
42
+ # them — and those tests fail intermittently while passing in isolation.
43
+ # These tests assert what the checks detect, not how fast the host is.
38
44
  jq -n --arg path "$MEM_DIR" \
39
45
  '{
40
46
  curator: {
41
47
  memory_store_path: $path,
48
+ cheap_checks: { wall_clock_budget_ms: 600000 },
42
49
  date_check: { date_grace_period_days: 7 }
43
50
  }
44
51
  }' > "${PROJECT_REPO}/.claude/settings.json"
@@ -93,8 +100,8 @@ _write_index() {
93
100
  # Surfacer rendered the pointer.
94
101
  local ctx
95
102
  ctx=$(echo "$output" | jq -r '.hookSpecificOutput.additionalContext')
96
- [[ "$ctx" == *"Curator: 1 open finding"* ]]
97
- [[ "$ctx" == *"date-decayed"* ]]
103
+ [[ "$ctx" == *"Curator: 1 open finding"* ]] || return 1
104
+ [[ "$ctx" == *"date-decayed"* ]] || return 1
98
105
  [[ "$ctx" == *"/curator review"* ]]
99
106
  }
100
107
 
@@ -256,7 +263,7 @@ BODY
256
263
  [ "$status" -eq 0 ]
257
264
  local ctx
258
265
  ctx=$(echo "$output" | jq -r '.hookSpecificOutput.additionalContext')
259
- [[ "$ctx" == *"2 date-decayed"* ]]
266
+ [[ "$ctx" == *"2 date-decayed"* ]] || return 1
260
267
  # The buggy output would have looked like "1 date-decayed, 1 date-decayed".
261
268
  [[ "$ctx" != *"1 date-decayed, 1 date-decayed"* ]]
262
269
  }
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env bats
2
+ #
3
+ # Guards the payload-default expansion in every emit helper.
4
+ #
5
+ # Two tempting forms are both wrong, and each fails in a way the other does not:
6
+ #
7
+ # "${3:-{\}}" keeps the backslash on bash 3.2 (the bash macOS ships, and the
8
+ # one `#!/usr/bin/env bash` resolves to there), yielding {\} —
9
+ # invalid JSON, so the emit silently drops the event. Works on
10
+ # bash 5.x, which is why CI never caught it.
11
+ # "${3:-{}}" appends a stray `}` to any payload that IS supplied, on EVERY
12
+ # bash version, corrupting the far more common path.
13
+ #
14
+ # The brace-free form below is correct on both. This test runs the real
15
+ # expansion under the real interpreter rather than asserting on source text.
16
+
17
+ setup() {
18
+ source "${BATS_TEST_DIRNAME}/../helpers/setup.bash"
19
+ setup_test_env
20
+ }
21
+
22
+ _emit_libs() {
23
+ printf '%s\n' \
24
+ "scripts/lib/prompt-rules.sh" \
25
+ "plugins/curator/scripts/lib/curator-emit.sh" \
26
+ "plugins/historian/scripts/lib/historian-emit.sh" \
27
+ "plugins/librarian/scripts/lib/librarian-emit.sh" \
28
+ "plugins/librarian/scripts/lib/librarian-cli.sh" \
29
+ "plugins/tribunal/scripts/lib/tribunal-gate.sh"
30
+ }
31
+
32
+ @test "no emit helper inlines braces in a parameter-expansion default" {
33
+ # Code only — a comment explaining the hazard must not trip its own guard.
34
+ local hits
35
+ hits=$(cd "$REPO_ROOT" && grep -rn ':-{' --include="*.sh" scripts/ plugins/ \
36
+ | grep -vE '^[^:]+:[0-9]+:[[:space:]]*#' || true)
37
+ [ -z "$hits" ]
38
+ }
39
+
40
+ @test "the brace-free default yields {} when no payload is passed" {
41
+ local probe="${BATS_TEST_TMPDIR}/probe.sh"
42
+ printf '%s\n' 'f() { local p="${3:-}"; [ -z "$p" ] && p='"'"'{}'"'"'; printf "%s" "$p"; }' 'f a b' >"$probe"
43
+ run bash "$probe"
44
+ [ "$status" -eq 0 ] && [ "$output" = '{}' ]
45
+ }
46
+
47
+ @test "the brace-free default passes a supplied payload through unchanged" {
48
+ local probe="${BATS_TEST_TMPDIR}/probe.sh"
49
+ printf '%s\n' 'f() { local p="${3:-}"; [ -z "$p" ] && p='"'"'{}'"'"'; printf "%s" "$p"; }' 'f a b '"'"'{"a":{"b":1}}'"'"'' >"$probe"
50
+ run bash "$probe"
51
+ [ "$status" -eq 0 ] && [ "$output" = '{"a":{"b":1}}' ]
52
+ }
@@ -91,7 +91,7 @@ _make_completion() {
91
91
  @test "governor_ledger_path returns a .jsonl path under ONLOOKER_DIR" {
92
92
  local p
93
93
  p=$(governor_ledger_path "test-session")
94
- [[ "$p" == *".jsonl" ]]
94
+ [[ "$p" == *".jsonl" ]] || return 1
95
95
  [[ "$p" == *"test-session"* ]]
96
96
  }
97
97
 
@@ -157,7 +157,7 @@ _index_session() {
157
157
 
158
158
  local ctx
159
159
  ctx=$(echo "$output" | jq -r '.hookSpecificOutput.additionalContext')
160
- [[ "$ctx" == *"Historian: a past chunk looks similar"* ]]
160
+ [[ "$ctx" == *"Historian: a past chunk looks similar"* ]] || return 1
161
161
  [[ "$ctx" == *"redash"* ]]
162
162
 
163
163
  grep '"event_type":"historian.retrieval.surfaced"' "$ONLOOKER_EVENTS_LOG" \
@@ -100,7 +100,7 @@ _run_hook() {
100
100
  echo '{"inspector":{"show_clean_runs":true,"checks":{".ts":[{"name":"clean","kind":"lint","argv":["true"]}]}}}' | _settings
101
101
  run _run_hook "$(_input)"
102
102
  [ "$status" -eq 0 ]
103
- [[ "$output" == *"inspector: src/sample.ts"* ]]
103
+ [[ "$output" == *"inspector: src/sample.ts"* ]] || return 1
104
104
  [[ "$output" == *"✓ clean"* ]]
105
105
  }
106
106
 
@@ -112,9 +112,9 @@ _run_hook() {
112
112
  EOF
113
113
  run _run_hook "$(_input)"
114
114
  [ "$status" -eq 0 ]
115
- [[ "$output" == *"inspector: src/sample.ts"* ]]
116
- [[ "$output" == *"✗ broken"* ]]
117
- [[ "$output" == *"src/sample.ts:1:1 - Bad"* ]]
115
+ [[ "$output" == *"inspector: src/sample.ts"* ]] || return 1
116
+ [[ "$output" == *"✗ broken"* ]] || return 1
117
+ [[ "$output" == *"src/sample.ts:1:1 - Bad"* ]] || return 1
118
118
  [ "$(_event_count inspector.check.failed)" = "1" ]
119
119
  [ "$(jq -r 'select(.event_type=="inspector.check.failed").payload.exit_code' "$ONLOOKER_EVENTS_LOG")" = "2" ]
120
120
  }
@@ -124,13 +124,13 @@ _seed_proposal() {
124
124
  run librarian_cli_list "$PROJECT_REPO"
125
125
  [ "$status" -eq 0 ]
126
126
  # Header counts only pending entries (2 of 3).
127
- [[ "$output" == *"2 pending proposal"* ]]
127
+ [[ "$output" == *"2 pending proposal"* ]] || return 1
128
128
  # Both pending titles surface.
129
- [[ "$output" == *"Prefer functional patterns"* ]]
130
- [[ "$output" == *"Auth rewrite is compliance"* ]]
129
+ [[ "$output" == *"Prefer functional patterns"* ]] || return 1
130
+ [[ "$output" == *"Auth rewrite is compliance"* ]] || return 1
131
131
  # Pending rows include full IDs that can be used with show/accept/reject/defer.
132
- [[ "$output" == *"01LISTPENDINGA000000000000"* ]]
133
- [[ "$output" == *"01LISTPENDINGB000000000000"* ]]
132
+ [[ "$output" == *"01LISTPENDINGA000000000000"* ]] || return 1
133
+ [[ "$output" == *"01LISTPENDINGB000000000000"* ]] || return 1
134
134
  # Accepted entry does NOT appear in the list output.
135
135
  [[ "$output" != *"Already accepted"* ]]
136
136
  }
@@ -142,10 +142,10 @@ _seed_proposal() {
142
142
 
143
143
  run librarian_cli_show "01SHOWPROPOSAL0000000000000" "$PROJECT_REPO"
144
144
  [ "$status" -eq 0 ]
145
- [[ "$output" == *"01SHOWPROPOSAL0000000000000"* ]]
146
- [[ "$output" == *"type: feedback"* ]]
147
- [[ "$output" == *"filename: feedback_x.md"* ]]
148
- [[ "$output" == *"classifier_confidence: 0.82"* ]]
145
+ [[ "$output" == *"01SHOWPROPOSAL0000000000000"* ]] || return 1
146
+ [[ "$output" == *"type: feedback"* ]] || return 1
147
+ [[ "$output" == *"filename: feedback_x.md"* ]] || return 1
148
+ [[ "$output" == *"classifier_confidence: 0.82"* ]] || return 1
149
149
  [[ "$output" == *"Body of the memory."* ]]
150
150
  }
151
151
 
@@ -165,7 +165,7 @@ _seed_proposal() {
165
165
 
166
166
  run librarian_cli_accept "01ACCEPTPROPOSAL000000000000" "$PROJECT_REPO"
167
167
  [ "$status" -eq 0 ]
168
- [[ "$output" == *"Accepted."* ]]
168
+ [[ "$output" == *"Accepted."* ]] || return 1
169
169
 
170
170
  local out_file="${MEM_DIR}/feedback_functional.md"
171
171
  [ -f "$out_file" ]
@@ -220,7 +220,7 @@ _seed_proposal() {
220
220
 
221
221
  run librarian_cli_accept "01ACCEPTUNSAFE00000000000000" "$PROJECT_REPO"
222
222
  [ "$status" -eq 1 ]
223
- [[ "$output" == *"Failed to write memory file."* ]]
223
+ [[ "$output" == *"Failed to write memory file."* ]] || return 1
224
224
 
225
225
  # No memory file written anywhere under MEM_DIR or its parent.
226
226
  [ ! -f "${MEM_DIR}/../escape.md" ]
@@ -238,8 +238,8 @@ _seed_proposal() {
238
238
 
239
239
  run librarian_cli_reject "01REJECTPROPOSAL00000000000" "stale guidance" "$PROJECT_REPO"
240
240
  [ "$status" -eq 0 ]
241
- [[ "$output" == *"Rejected"* ]]
242
- [[ "$output" == *"stale guidance"* ]]
241
+ [[ "$output" == *"Rejected"* ]] || return 1
242
+ [[ "$output" == *"stale guidance"* ]] || return 1
243
243
 
244
244
  # Proposal status now rejected with the reason captured.
245
245
  local proposal_path="${LIBRARIAN_DIR}/proposals/01REJECTPROPOSAL00000000000.json"
@@ -268,7 +268,7 @@ _seed_proposal() {
268
268
 
269
269
  run librarian_cli_defer "01DEFERPROPOSAL000000000000" "$PROJECT_REPO"
270
270
  [ "$status" -eq 0 ]
271
- [[ "$output" == *"Deferred"* ]]
271
+ [[ "$output" == *"Deferred"* ]] || return 1
272
272
 
273
273
  local proposal_path="${LIBRARIAN_DIR}/proposals/01DEFERPROPOSAL000000000000.json"
274
274
  jq -e '.status == "pending"' "$proposal_path" >/dev/null
@@ -285,8 +285,8 @@ _seed_proposal() {
285
285
 
286
286
  run librarian_cli_status "$PROJECT_REPO"
287
287
  [ "$status" -eq 0 ]
288
- [[ "$output" == *"pending: 1"* ]]
289
- [[ "$output" == *"accepted: 1"* ]]
288
+ [[ "$output" == *"pending: 1"* ]] || return 1
289
+ [[ "$output" == *"accepted: 1"* ]] || return 1
290
290
  [[ "$output" == *"rejected: 1"* ]]
291
291
  }
292
292
 
@@ -83,7 +83,7 @@ _seed_proposal() {
83
83
  [ "$status" -eq 0 ]
84
84
  local ctx
85
85
  ctx=$(echo "$output" | jq -r '.hookSpecificOutput.additionalContext')
86
- [[ "$ctx" == *"Librarian has 3 pending memory promotion proposals"* ]]
86
+ [[ "$ctx" == *"Librarian has 3 pending memory promotion proposals"* ]] || return 1
87
87
  [[ "$ctx" == *"/librarian review"* ]]
88
88
  }
89
89
 
@@ -94,7 +94,7 @@ _seed_proposal() {
94
94
  [ "$status" -eq 0 ]
95
95
  local ctx
96
96
  ctx=$(echo "$output" | jq -r '.hookSpecificOutput.additionalContext')
97
- [[ "$ctx" == *"Librarian has 1 pending memory promotion proposal"* ]]
97
+ [[ "$ctx" == *"Librarian has 1 pending memory promotion proposal"* ]] || return 1
98
98
  [[ "$ctx" != *"proposals."* ]]
99
99
  }
100
100
 
@@ -43,6 +43,6 @@ setup() {
43
43
  lineage_config_load ""
44
44
  run lineage_config_ignore_globs
45
45
  [ "$status" -eq 0 ]
46
- [[ "$output" == *"node_modules"* ]]
46
+ [[ "$output" == *"node_modules"* ]] || return 1
47
47
  [[ "$output" == *".lock"* ]]
48
48
  }
@@ -21,7 +21,7 @@ setup() {
21
21
  local tok out
22
22
  tok="sk-ant-$(printf 'a%.0s' $(seq 1 28))"
23
23
  out=$(printf '%s' "key=\"${tok}\"" | lineage_redact 4000 true)
24
- [[ "$out" == *"[REDACTED:secret]"* ]]
24
+ [[ "$out" == *"[REDACTED:secret]"* ]] || return 1
25
25
  [[ "$out" != *"$tok"* ]]
26
26
  }
27
27
 
@@ -29,7 +29,7 @@ setup() {
29
29
  local tok out
30
30
  tok="ghp_$(printf '0%.0s' $(seq 1 36))"
31
31
  out=$(printf '%s' "$tok" | lineage_redact 4000 true)
32
- [[ "$out" == *"[REDACTED:secret]"* ]]
32
+ [[ "$out" == *"[REDACTED:secret]"* ]] || return 1
33
33
  [[ "$out" != *"$tok"* ]]
34
34
  }
35
35
 
@@ -37,8 +37,8 @@ setup() {
37
37
  local val out
38
38
  val=$(printf 'x%.0s' $(seq 1 24))
39
39
  out=$(printf '%s' "API_TOKEN=${val}" | lineage_redact 4000 true)
40
- [[ "$out" == *"API_TOKEN="* ]]
41
- [[ "$out" == *"[REDACTED:secret]"* ]]
40
+ [[ "$out" == *"API_TOKEN="* ]] || return 1
41
+ [[ "$out" == *"[REDACTED:secret]"* ]] || return 1
42
42
  [[ "$out" != *"$val"* ]]
43
43
  }
44
44
 
@@ -52,7 +52,7 @@ setup() {
52
52
  @test "content longer than the cap is truncated with a marker" {
53
53
  local out
54
54
  out=$(printf '%s' "abcdefghij" | lineage_redact 4 true)
55
- [[ "$out" == "abcd"* ]]
55
+ [[ "$out" == "abcd"* ]] || return 1
56
56
  [[ "$out" == *"truncated 6 chars"* ]]
57
57
  }
58
58
 
@@ -90,7 +90,7 @@ seed_start_ms_ago() {
90
90
  @test "session_tracker_now_ms returns 13-digit epoch milliseconds" {
91
91
  local ms
92
92
  ms=$(session_tracker_now_ms)
93
- [[ "$ms" =~ ^[0-9]+$ ]]
93
+ [[ "$ms" =~ ^[0-9]+$ ]] || return 1
94
94
  [ "${#ms}" -eq 13 ]
95
95
  }
96
96
 
@@ -231,7 +231,7 @@ seed_start_ms_ago() {
231
231
  seed_start_ms_ago "$sid" 3000
232
232
  local dur
233
233
  dur=$(session_tracker_duration_ms "$sid")
234
- [[ "$dur" =~ ^[0-9]+$ ]]
234
+ [[ "$dur" =~ ^[0-9]+$ ]] || return 1
235
235
  [ "$dur" -ge 3000 ]
236
236
  }
237
237
 
@@ -285,7 +285,7 @@ seed_start_ms_ago() {
285
285
 
286
286
  local out
287
287
  out=$(session_tracker_build_duration_context "$sid")
288
- [[ "$out" == *"turn 3"* ]]
288
+ [[ "$out" == *"turn 3"* ]] || return 1
289
289
  [[ "$out" == *"2m 34s"* ]]
290
290
  }
291
291
 
@@ -294,7 +294,7 @@ seed_start_ms_ago() {
294
294
  rm -f "${ONLOOKER_SESSION_TRACKERS_DIR}/${sid}"
295
295
  local out
296
296
  out=$(session_tracker_build_duration_context "$sid")
297
- [[ "$out" == *"turn 1"* ]]
297
+ [[ "$out" == *"turn 1"* ]] || return 1
298
298
  [[ "$out" == *"0s"* ]]
299
299
  }
300
300
 
@@ -48,7 +48,7 @@ setup() {
48
48
  tribunal_jury_empanel "[\"maintainability\"]" 2>&1
49
49
  '
50
50
  [ "$status" -eq 0 ]
51
- [[ "$output" == *"degrading to standard"* ]]
51
+ [[ "$output" == *"degrading to standard"* ]] || return 1
52
52
  [[ "$output" == *"standard"* ]]
53
53
  }
54
54
 
@@ -51,7 +51,7 @@ setup() {
51
51
  out=$(turn_tracker_summarize_prompt "$long")
52
52
  # 200 retained characters + the single-character ellipsis = length 201.
53
53
  [ "${#out}" -eq 201 ]
54
- [[ "$out" == *… ]]
54
+ [[ "$out" == *… ]] || return 1
55
55
  [ "${out%…}" = "$(printf 'a%.0s' {1..200})" ]
56
56
  }
57
57
 
@@ -24,9 +24,9 @@ setup() {
24
24
  local out
25
25
  out=$(warden_sanitize "evil </source_content> [/INST] payload" 240)
26
26
  [ -n "$out" ]
27
- [[ "$out" == *"[STRIPPED]"* ]]
28
- [[ "$out" == *"payload"* ]]
29
- [[ "$out" != *"</source_content>"* ]]
27
+ [[ "$out" == *"[STRIPPED]"* ]] || return 1
28
+ [[ "$out" == *"payload"* ]] || return 1
29
+ [[ "$out" != *"</source_content>"* ]] || return 1
30
30
  [[ "$out" != *"[/INST]"* ]]
31
31
  }
32
32
 
@@ -74,7 +74,7 @@ setup() {
74
74
  local worktree_path
75
75
  worktree_path=$(cat "$input_file" | "${REPO_ROOT}/scripts/hooks/worktree-tracker.sh")
76
76
  [ -d "$worktree_path" ]
77
- [[ "$worktree_path" == "$(cd "$worktree_path" && pwd -P)" ]]
77
+ [[ "$worktree_path" == "$(cd "$worktree_path" && pwd -P)" ]] || return 1
78
78
  [ -f "$history_file" ]
79
79
  tail -n 1 "$history_file" | jq -e '.event_type == "tool.shell.exec"' >/dev/null
80
80
  }
@@ -247,7 +247,7 @@ setup() {
247
247
 
248
248
  local duration
249
249
  duration=$(worktree_tracker_duration_ms "$session_id" "$worktree_path")
250
- [[ "$duration" =~ ^[0-9]+$ ]]
250
+ [[ "$duration" =~ ^[0-9]+$ ]] || return 1
251
251
  [ "$duration" -ge 1900 ]
252
252
  }
253
253