Skip to content

fix(obsidian): seed per-vault config and enable openclaw OTLP - #1450

Merged
shunkakinoki merged 3 commits into
mainfrom
fix/obsidian-wiki-json-and-openclaw-otlp
Apr 12, 2026
Merged

fix(obsidian): seed per-vault config and enable openclaw OTLP#1450
shunkakinoki merged 3 commits into
mainfrom
fix/obsidian-wiki-json-and-openclaw-otlp

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Apr 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Obsidian fix: activate.sh now seeds missing <vault-id>.json files (e.g. wiki.json) in ~/.config/obsidian/ on activation. This eliminates the ENOENT: no such file or directory, open '/home/ubuntu/.config/obsidian/wiki.json' error logged on every daemon restart.
  • OpenClaw OTLP: Enables diagnostics-otel plugin and adds top-level diagnostics config block to both template files with traces, metrics, and logs over http/protobuf.
  • Removed the chmod 644 on obsidian.json so Obsidian can write back to it (update timestamps, vault state) without EACCES errors during activation races.

Test plan

  • shellspec spec/activate_config_spec.sh passes (25 examples, 0 failures)
  • shellspec spec/openclaw_hydrate_spec.sh passes (20 examples, 0 failures)
  • Both JSON templates validate
  • Tested activate.sh creates wiki.json for new vaults and preserves existing ones
  • Manually seeded wiki.json on kyber - next obsidian restart should be clean

Summary by cubic

Turns on OpenClaw OTLP telemetry (http/protobuf) and auto-wires the endpoint to the in-cluster Alloy collector during hydration. Adds a top-level diagnostics block and enables the diagnostics-otel plugin in both templates.

  • New Features
    • Add diagnostics.otel config in openclaw.template.json and openclaw.tpl.json (serviceName "openclaw"; traces, metrics, logs enabled; endpoint placeholder __OTEL_ENDPOINT__).
    • Hydration resolves __OTEL_ENDPOINT__ to http://<Alloy ClusterIP>:4318 via kubectl, falling back to http://localhost:4318.

Written for commit 3e5a7f6. Summary will update on new commits.

- Obsidian headless daemon logs ENOENT on every start because
  wiki.json (per-vault config) was never created by activate.sh.
  Now seeds missing <vault-id>.json files with {} on activation.
- Enable diagnostics-otel plugin and top-level diagnostics config
  in both openclaw templates (traces, metrics, logs via http/protobuf).
@mesa-dot-dev

mesa-dot-dev Bot commented Apr 12, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@coderabbitai

coderabbitai Bot commented Apr 12, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@shunkakinoki has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 2 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 3 minutes and 2 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fe281fdb-b378-47af-85ae-55c19b2c806e

📥 Commits

Reviewing files that changed from the base of the PR and between a7f9e52 and 3e5a7f6.

📒 Files selected for processing (3)
  • config/openclaw/hydrate.sh
  • config/openclaw/openclaw.template.json
  • config/openclaw/openclaw.tpl.json
📝 Walkthrough

Walkthrough

The pull request updates Obsidian configuration generation to derive a consistent OBS_DIR variable and introduces Python logic to seed per-vault JSON config files. It concurrently adds OpenTelemetry diagnostics configuration with HTTP/Protobuf protocol support to OpenClaw's template configurations.

Changes

Cohort / File(s) Summary
Obsidian Configuration
config/obsidian/activate.sh
Added OBS_DIR variable derivation, modified output path to use the variable, and introduced Python snippet to iterate over vault IDs and seed missing per-vault JSON config files with empty objects.
OpenClaw Diagnostics
config/openclaw/openclaw.template.json, config/openclaw/openclaw.tpl.json
Added top-level diagnostics configuration with OpenTelemetry enabled, HTTP/Protobuf protocol, service name "openclaw", and enabled traces/metrics/logs. Added corresponding diagnostics-otel plugin entry.
Obsidian Activation Tests
spec/activate_config_spec.sh
Updated assertion to check for OBS_DIR identifier in output. Added new test case validating that activate.sh contains logic to seed per-vault config files (matching wiki.json, vault.*json, or vid.*json patterns).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 In config files, a rabbit did hop,
With vaults and diagnostics without a stop,
Seeds planted in JSON so neat,
OTelemetry's beat—observability's sweet!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: seeding per-vault Obsidian config files and enabling OpenClaw OTLP diagnostics, which are the primary objectives of the changeset.
Description check ✅ Passed The description directly addresses the changeset, detailing the Obsidian fix for seeding vault config files, OpenClaw OTLP enablement, permission changes, and comprehensive test verification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/obsidian-wiki-json-and-openclaw-otlp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mesa-dot-dev

mesa-dot-dev Bot commented Apr 12, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Fixes Obsidian config seeding for per-vault JSON files and enables OpenClaw OTLP diagnostics via diagnostics-otel plugin and new config blocks.

What changed?

  • activate.sh now seeds missing <vault-id>.json files in ~/.config/obsidian/ on activation and removes chmod 644 on obsidian.json to prevent write errors.
  • config/openclaw/openclaw.template.json: Updated to include a new diagnostics configuration block, enabling OpenTelemetry with HTTP/protobuf protocol, openclaw as service name, and support for traces, metrics, and logs. diagnostics-otel plugin added and enabled.
  • config/openclaw/openclaw.tpl.json: Introduced a new diagnostics configuration block to enable OpenTelemetry for traces, metrics, and logs using http/protobuf protocol and openclaw as service name. diagnostics-otel plugin enabled within plugins.load.paths.

Description generated by Mesa. Update settings

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces vault configuration seeding in the Obsidian activation script and enables OpenTelemetry diagnostics for OpenClaw. Feedback suggests improving the robustness of the Python seeding script by handling potential errors, ensuring proper file closure, and allowing the Python binary path to be configurable. Additionally, it is recommended to replace the brittle string-matching tests with functional tests that verify the actual creation of configuration files.

I am having trouble creating individual review comments. Click here to see my feedback.

config/obsidian/activate.sh (17-25)

high

The script relies on a global python3 binary, which may not be available in the restricted environment where Nix activation scripts run. It is better to pass the path to the Python binary from Nix, similar to how SED_BIN is handled. Additionally, the Python script could be more robust by handling cases where the vaults key might be null and ensuring file handles are closed properly.

  "${4:-python3}" -c '
import json, sys, os
try:
    with open(sys.argv[1]) as f:
        cfg = json.load(f)
    obs_dir = sys.argv[2]
    for vid in (cfg.get("vaults") or {}):
        p = os.path.join(obs_dir, vid + ".json")
        if not os.path.exists(p):
            with open(p, "w") as f: f.write("{}")
except Exception as e:
    print(f"Warning: Failed to seed vault configs: {e}", file=sys.stderr)
' "$OBS_DIR/obsidian.json" "$OBS_DIR"
References
  1. Maintain consistency with established patterns for writing scripts that are extracted from Nix expressions.

spec/activate_config_spec.sh (150-153)

medium

This test only verifies that the script contains certain strings (like vid.*json), which does not guarantee that the logic for seeding vault configurations actually works. It is a change detector test that is brittle and does not verify behavior. Consider adding a functional test that checks for the actual existence of the seeded files in a temporary directory.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
spec/activate_config_spec.sh (1)

150-153: Prefer behavior-based spec over pattern grep for seeding logic.

Line [151] asserts source text patterns, so this can pass even if runtime seeding is broken. Consider running the script in a temp HOME and asserting actual file creation/preservation.

Example direction
-It 'seeds missing per-vault config files'
-When run bash -c "grep 'wiki.json\|vault.*json\|vid.*json' '$SCRIPT'"
-The output should not equal ''
+It 'seeds missing per-vault config files'
+When run bash -c '
+  set -euo pipefail
+  tmp="$(mktemp -d)"
+  cfg="$tmp/obsidian.json"
+  cat > "$cfg" <<EOF
+{"vaults":{"wiki":{"path":"__HOME_DIR__/wiki","ts":0,"open":true}}}
+EOF
+  bash "$SCRIPT" "$cfg" "$tmp" sed
+  test -f "$tmp/.config/obsidian/wiki.json"
+'
+The status should equal 0
 End
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@spec/activate_config_spec.sh` around lines 150 - 153, Replace the fragile
grep-based assertion in the "seeds missing per-vault config files" example with
a behavior-driven test that runs the target script ($SCRIPT) in an isolated
temporary HOME and asserts that the expected files are actually
created/preserved on disk; specifically, create a temp dir (mktemp -d), set HOME
to it, invoke bash -c "$SCRIPT", then check for existence of the concrete files
(e.g., wiki.json, vault*.json, vid*.json) with test -f or [ -e ] and fail the
spec if any expected file is missing, ensuring you reference the same test name
("seeds missing per-vault config files") and the $SCRIPT variable when updating
the spec.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@config/openclaw/openclaw.template.json`:
- Around line 902-911: The template enables telemetry logs by default
("diagnostics" -> "otel" -> "logs": true); change that value to false so runtime
logs are opt-in rather than exported by default, i.e., update the otel.logs
setting under the diagnostics object (the "diagnostics" / "otel" block) to
"logs": false.

In `@config/openclaw/openclaw.tpl.json`:
- Around line 902-911: The template enables OTLP logs by default which is too
permissive; change the default under the "diagnostics" -> "otel" block so "logs"
is false (or remove it to require explicit opt-in) and update any related
documentation or config comments to instruct consumers to opt in if they need
log export; look for the "diagnostics", "otel", "serviceName" and "logs" keys in
the openclaw.tpl.json and make "logs": false (or drop the key) to make log
export opt-in.

---

Nitpick comments:
In `@spec/activate_config_spec.sh`:
- Around line 150-153: Replace the fragile grep-based assertion in the "seeds
missing per-vault config files" example with a behavior-driven test that runs
the target script ($SCRIPT) in an isolated temporary HOME and asserts that the
expected files are actually created/preserved on disk; specifically, create a
temp dir (mktemp -d), set HOME to it, invoke bash -c "$SCRIPT", then check for
existence of the concrete files (e.g., wiki.json, vault*.json, vid*.json) with
test -f or [ -e ] and fail the spec if any expected file is missing, ensuring
you reference the same test name ("seeds missing per-vault config files") and
the $SCRIPT variable when updating the spec.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ce198287-adf1-4a06-9565-defcd193f288

📥 Commits

Reviewing files that changed from the base of the PR and between 2796cfd and a7f9e52.

📒 Files selected for processing (4)
  • config/obsidian/activate.sh
  • config/openclaw/openclaw.template.json
  • config/openclaw/openclaw.tpl.json
  • spec/activate_config_spec.sh

Comment on lines +902 to +911
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"protocol": "http/protobuf",
"serviceName": "openclaw",
"traces": true,
"metrics": true,
"logs": true
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Keep telemetry logs opt-in in the concrete template as well.

Line 910 sets "logs": true here too, so sensitive runtime logs may be exported by default. Align this with a safer default (false) unless explicitly required per environment.

Proposed change
   "diagnostics": {
     "enabled": true,
     "otel": {
       "enabled": true,
       "protocol": "http/protobuf",
       "serviceName": "openclaw",
       "traces": true,
       "metrics": true,
-      "logs": true
+      "logs": false
     }
   },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/openclaw/openclaw.template.json` around lines 902 - 911, The template
enables telemetry logs by default ("diagnostics" -> "otel" -> "logs": true);
change that value to false so runtime logs are opt-in rather than exported by
default, i.e., update the otel.logs setting under the diagnostics object (the
"diagnostics" / "otel" block) to "logs": false.

Comment on lines +902 to +911
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"protocol": "http/protobuf",
"serviceName": "openclaw",
"traces": true,
"metrics": true,
"logs": true
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Default OTLP log export is too permissive for a base template.

Line 910 sets "logs": true globally. In a shared template, that can forward sensitive runtime content by default. Safer default is opt-in logs.

Proposed change
   "diagnostics": {
     "enabled": true,
     "otel": {
       "enabled": true,
       "protocol": "http/protobuf",
       "serviceName": "openclaw",
       "traces": true,
       "metrics": true,
-      "logs": true
+      "logs": false
     }
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"protocol": "http/protobuf",
"serviceName": "openclaw",
"traces": true,
"metrics": true,
"logs": true
}
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"protocol": "http/protobuf",
"serviceName": "openclaw",
"traces": true,
"metrics": true,
"logs": false
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/openclaw/openclaw.tpl.json` around lines 902 - 911, The template
enables OTLP logs by default which is too permissive; change the default under
the "diagnostics" -> "otel" block so "logs" is false (or remove it to require
explicit opt-in) and update any related documentation or config comments to
instruct consumers to opt in if they need log export; look for the
"diagnostics", "otel", "serviceName" and "logs" keys in the openclaw.tpl.json
and make "logs": false (or drop the key) to make log export opt-in.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="config/obsidian/activate.sh">

<violation number="1">
P1: Activation no longer seeds missing per-vault `<vault-id>.json` files, so new/missing vault configs will trigger ENOENT errors again.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@shunkakinoki
shunkakinoki merged commit 85a1eac into main Apr 12, 2026
5 checks passed
@shunkakinoki
shunkakinoki deleted the fix/obsidian-wiki-json-and-openclaw-otlp branch April 12, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant