Skip to content

fix(ci): unbreak shell-inline-check on main - #1487

Merged
shunkakinoki merged 4 commits into
mainfrom
claude/fix-failing-actions-pEcGG
Apr 17, 2026
Merged

fix(ci): unbreak shell-inline-check on main#1487
shunkakinoki merged 4 commits into
mainfrom
claude/fix-failing-actions-pEcGG

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Apr 16, 2026

Copy link
Copy Markdown
Owner

Summary

shell-inline-check has been failing on main since the check was introduced. Two bugs, one fix each:

  • Undefined awk iteration order. scripts/check-nix-inline-scripts.sh walked home.activation block lines with for (i in lines), whose order is indeterminate. Continuation lines ("arg" \) were often inspected before the bash-delegate line that's supposed to set saw_bash_call = 1, so every multi-line activation block in named-hosts/kyber, named-hosts/matic, and home-manager/modules/tailscale tripped the "unknown-line" branch. Switched to an ordered for (i = 1; i <= n; i++) using the count returned by split.
  • Inline dolt start script. home-manager/services/dolt/default.nix had a pkgs.writeShellScript with a large inline string, which the first check rejects. Extracted it to home-manager/services/dolt/start.sh and wired it up through pkgs.replaceVars, matching the pattern already used for obsidian/docker services. The ${beadsDir} and ${pkgs.dolt} interpolations become @beadsDir@ / @dolt@ placeholders.

Test plan

  • bash scripts/check-nix-inline-scripts.shNo inline shell or Python scripts in Nix files
  • bash -n on both touched shell scripts
  • CI shell-inline-check green on this PR

https://claude.ai/code/session_017g5bYHcPU5fBNebzkrX3td


Summary by cubic

Fixes the failing CI shell-inline-check on main and a fishtape error. Orders AWK line processing, extracts the Dolt start script, adds tests/coverage, and stringifies the path for launchd ProgramArguments.

  • Bug Fixes
    • Iterate AWK block lines in order (1..n) to avoid false positives on multi-line home.activation blocks.
    • Extract Dolt start script to home-manager/services/dolt/start.sh via pkgs.replaceVars; add spec/dolt_start_spec.sh and register it in spec/coverage_spec.sh (widen placeholder-stripping regex for bash -n).
    • Pass a string path to launchd ProgramArguments by interpolating "${startScript}"; remove a stray test in fishtape assertions to prevent double-wrapping in spec/fish/__tmux_bootstrap_default_session_test.fish.

Written for commit dc7a8c0. Summary will update on new commits.

… inline script

The awk check used `for (i in lines)` which has undefined iteration order,
so continuation lines were often checked before the bash-delegate line,
producing false positives on every multi-line `home.activation` block.
Iterate 1..n so the bash-call gate flips before its continuations are seen.

Also extract the dolt startScript to an external start.sh referenced via
pkgs.replaceVars, matching the pattern used by obsidian/docker services.
@coderabbitai

coderabbitai Bot commented Apr 16, 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 29 minutes and 51 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 29 minutes and 51 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: 70d3a790-a423-465a-870c-6e219ca90a9c

📥 Commits

Reviewing files that changed from the base of the PR and between 0c50928 and dc7a8c0.

📒 Files selected for processing (3)
  • home-manager/services/dolt/default.nix
  • spec/dolt_start_spec.sh
  • spec/fish/__tmux_bootstrap_default_session_test.fish
📝 Walkthrough

Walkthrough

Extracted the inline dolt service startup logic from Nix configuration into an external shell script, delegating control flow (directory creation, migration, symlinking, and SQL server execution) to ./start.sh with variable substitution at build time. Added corresponding test coverage and fixed deterministic line-iteration in a shell utility script.

Changes

Cohort / File(s) Summary
Dolt Service Refactoring
home-manager/services/dolt/default.nix, home-manager/services/dolt/start.sh
Extracted inline startScript logic into external start.sh file; script handles directory creation, legacy dolt-to-df migration, symlink setup, and dolt SQL server invocation with host/port/data-dir configuration.
Test Coverage & Specs
spec/coverage_spec.sh, spec/dolt_start_spec.sh
Added test mapping for the new start script and comprehensive spec validating shebang, strict mode, syntax, placeholder usage, migration behavior (mv/ln commands), and SQL server binding details (127.0.0.1:3307).
Script Utility Fix
scripts/check-nix-inline-scripts.sh
Updated AWK block_has_violation function to make line-iteration deterministic by capturing split() return value into dedicated n variable instead of relying on loop variable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 A script hops free from Nix's tight embrace,
To start.sh it bounds with grace and space,
With @beadsDir@ and @dolt@ in sight,
Migration flows, symlinks align just right,
Tests confirm all logic shines so bright! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing the broken shell-inline-check CI on main by addressing specific bugs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description clearly explains the two bugs being fixed (AWK iteration order and inline dolt start script), the extracted changes made, and the test plan validating the fixes.

✏️ 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 claude/fix-failing-actions-pEcGG

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 16, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Fixes the failing CI shell-inline-check by ordering AWK line processing in scripts/check-nix-inline-scripts.sh, extracting an inline Dolt start script to home-manager/services/dolt/start.sh with pkgs.replaceVars, and stringifying the launchd ProgramArguments for the script path.

What changed?

  • scripts/check-nix-inline-scripts.sh: Refactored block_has_violation to use an ordered for (i = 1; i <= n; i++) loop for AWK processing, resolving indeterminate iteration order that caused false positives on multi-line home.activation blocks.
  • home-manager/services/dolt/default.nix: Externalized the Dolt startup script from an inline string to a separate start.sh file. Now uses pkgs.replaceVars for variable substitution and explicitly interpolates "${startScript}" in the launchd ProgramArguments to ensure a string path.
  • home-manager/services/dolt/start.sh: New script containing the Dolt database service startup logic, extracted from default.nix.
  • spec/dolt_start_spec.sh: Added a comprehensive test suite for the new home-manager/services/dolt/start.sh script, verifying its properties, placeholder substitutions, Dolt directory migration, and sql-server invocation.
  • spec/coverage_spec.sh: Updated to include spec/dolt_start_spec.sh in the coverage check list and adjusted the placeholder-stripping regex for bash -n.

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 refactors the Dolt service by moving its start script to an external file and utilizing pkgs.replaceVars for variable substitution. Additionally, it improves the reliability of the check-nix-inline-scripts.sh script by ensuring ordered iteration over lines in AWK. Feedback was provided regarding the use of builtins.readFile on a derivation, which introduces an Import From Derivation (IFD) that could impact evaluation performance; using pkgs.substituteAll is recommended as a more efficient alternative.

Comment on lines +14 to +21
startScript = pkgs.writeShellScript "dotfiles-dolt-start.sh" (
builtins.readFile (
pkgs.replaceVars ./start.sh {
inherit beadsDir;
inherit (pkgs) dolt;
}
)
);

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.

medium

This implementation uses builtins.readFile on a derivation produced by pkgs.replaceVars, which is an Import From Derivation (IFD). IFD can cause performance issues during Nix evaluation because it forces a build to happen before evaluation can continue.

Since this follows an existing pattern in the repository, it may be acceptable, but a more efficient alternative would be to use pkgs.substituteAll to create the script derivation directly, avoiding the need to read the file back into Nix memory.

The coverage_spec.sh diffs `git ls-files '*.sh'` against the covered_scripts
allowlist and fails shell-test if either side has an entry the other doesn't.
Register the new script and add a basic spec covering shebang, strict mode,
placeholder tokens, migration behavior, and sql-server flags.
@shunkakinoki
shunkakinoki marked this pull request as ready for review April 17, 2026 07:56
@mesa-dot-dev

mesa-dot-dev Bot commented Apr 17, 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 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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
home-manager/services/dolt/default.nix (1)

27-27: ⚠️ Potential issue | 🔴 Critical

ProgramArguments expects strings, not derivations — add string interpolation.

CI reports type validation failure:

definition for option ...launchd.agents.dolt.config.ProgramArguments... is not of type string. Definition value: <derivation dotfiles-dolt-start.sh>.

pkgs.writeShellScript returns a derivation, but ProgramArguments list items must be strings. All similar usages in the codebase (cliproxyapi, tmux-session-logger, code-syncer, and others) coerce script variables with string interpolation. Apply the same pattern:

-      ProgramArguments = [ startScript ];
+      ProgramArguments = [ "${startScript}" ];
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@home-manager/services/dolt/default.nix` at line 27, ProgramArguments
currently contains a derivation (startScript produced by pkgs.writeShellScript)
but must be a list of strings; update the launchd config to interpolate the
script path into a string (e.g. use "${startScript}" style interpolation) so
ProgramArguments contains string values. Locate the ProgramArguments entry and
replace the raw startScript symbol with a string-interpolated version (same
pattern used for cliproxyapi, tmux-session-logger, code-syncer) ensuring
startScript remains created via pkgs.writeShellScript but is referenced as a
string in ProgramArguments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@spec/dolt_start_spec.sh`:
- Around line 18-21: The sed placeholder regex in the test "passes bash syntax
check after stripping placeholders" is too narrow (currently
's|@[a-z_]*@|/usr|g') and misses placeholders with uppercase letters or digits;
update the sed expression used in the bash -c invocation to a broader pattern
such as 's|@[A-Za-z_][A-Za-z0-9_]*@|/usr|g' so `@beadsDir`@ and similar
placeholders are stripped before running bash -n.

---

Outside diff comments:
In `@home-manager/services/dolt/default.nix`:
- Line 27: ProgramArguments currently contains a derivation (startScript
produced by pkgs.writeShellScript) but must be a list of strings; update the
launchd config to interpolate the script path into a string (e.g. use
"${startScript}" style interpolation) so ProgramArguments contains string
values. Locate the ProgramArguments entry and replace the raw startScript symbol
with a string-interpolated version (same pattern used for cliproxyapi,
tmux-session-logger, code-syncer) ensuring startScript remains created via
pkgs.writeShellScript but is referenced as a string in ProgramArguments.
🪄 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: edcbeb7e-3b82-4714-a8ab-34f5d50aafab

📥 Commits

Reviewing files that changed from the base of the PR and between a9669de and 0c50928.

📒 Files selected for processing (5)
  • home-manager/services/dolt/default.nix
  • home-manager/services/dolt/start.sh
  • scripts/check-nix-inline-scripts.sh
  • spec/coverage_spec.sh
  • spec/dolt_start_spec.sh

Comment thread spec/dolt_start_spec.sh

@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 5 files

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="spec/dolt_start_spec.sh">

<violation number="1" location="spec/dolt_start_spec.sh:19">
P2: The placeholder-stripping regex misses camelCase placeholders (e.g. `@beadsDir@`), so this syntax-check test is weaker than intended.</violation>
</file>

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

Comment thread spec/dolt_start_spec.sh Outdated
claude added 2 commits April 17, 2026 08:04
nix-darwin on galactica was failing with:
  definition for option `launchd.agents.dolt.config.ProgramArguments'
  is not of type `string'. Definition value: <derivation dotfiles-dolt-start.sh>

`pkgs.writeShellScript` returns a derivation; ProgramArguments expects
strings, so interpolate to coerce to the store path, matching the
pattern used by cliproxyapi/tmux-session-logger/code-syncer.

Also widen the placeholder-stripping regex in dolt_start_spec.sh so it
catches camelCase tokens like @beadsDir@ (previously only lowercase was
stripped, making the bash -n smoke test weaker than intended).
fishtape wraps the remaining arguments of @test with `test`, so

  @test "unknown session returns failure" test \$unknown_status -ne 0

expanded to `test test 1 -ne 0` (5 args) which fish's test rejects,
causing shell-test to fail since PR #1479 introduced this spec.
Drop the literal `test` so fishtape produces `test 1 -ne 0`.
@shunkakinoki
shunkakinoki merged commit 56f68b0 into main Apr 17, 2026
35 checks passed
@shunkakinoki
shunkakinoki deleted the claude/fix-failing-actions-pEcGG branch April 17, 2026 08:53
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.

2 participants