Skip to content

Add a SessionStart hook for Claude Code cloud sessions - #325

Open
matt-edmondson wants to merge 3 commits into
mainfrom
claude/cloud-session-setup-luxi33
Open

matt-edmondson wants to merge 3 commits into
mainfrom
claude/cloud-session-setup-luxi33

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Requested by Matt · project thread

Before: a Claude Code cloud session had no .NET SDK, so nothing here could be built or tested. Ubuntu's own dotnet-sdk-10.0 package does not help either: it is the 10.0.1xx band, which this repository's global.json (10.0.400) refuses, and whose compiler is too old for ktsu.Sdk.Analyzers (CS9057).

After: a SessionStart hook installs the SDK global.json asks for (10.0.402 today) plus the .NET 8 and 9 runtimes into ~/.dotnet, puts it on the session's PATH, and runs dotnet restore. The older runtimes matter here: Schema.Test runs on net8.0 and net9.0 as well, and without them two of its three runs fail to launch (exit code 150).

How: .claude/hooks/install-dotnet.sh tries the official dotnet-install.sh first. The default cloud network policy blocks builds.dotnet.microsoft.com but allows mcr.microsoft.com, so it falls back to unpacking usr/share/dotnet from the official mcr.microsoft.com/dotnet/sdk and runtime image layers. If the environment later allows the Microsoft host, the first route takes over with no change here. The hook does nothing outside cloud sessions and is a no-op once everything is installed. The same two files go to every ktsu repo in the Holotype project.

Validated in a cloud container: the hook ran clean and dotnet test --project Schema.Test/Schema.Test.csproj passed 1632/1632 across its three target frameworks.

Note: no version tag in the commit, so KtsuBuild will pick the bump from the files changed. Add [skip ci] or a tag on merge if a release for this is unwanted.


Generated by Claude Code

The cloud image has no .NET SDK, and Ubuntu's own dotnet-sdk-10.0 is the
1xx feature band, whose compiler is too old for ktsu.Sdk.Analyzers
(CS9057). The hook installs the SDK global.json asks for into ~/.dotnet,
puts it on the session's PATH and restores the solution.

dotnet-install.sh is tried first. The default cloud network policy blocks
builds.dotnet.microsoft.com, so the SDK falls back to the layers of the
mcr.microsoft.com/dotnet/sdk image, which the policy allows.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FGcrXbknJ2JWPDzNoNhPCw
@matt-edmondson matt-edmondson self-assigned this Oct 20, 2026
Comment thread .claude/hooks/install-dotnet.sh Outdated
Comment on lines +84 to +87
for layer in $(jq -r '.layers[].digest' <<<"$manifest"); do
curl -fsSL -o "$work/layer.tgz" "$registry/blobs/$layer"
tar -xzf "$work/layer.tgz" -C "$root" --strip-components=3 --wildcards "$wanted" 2>/dev/null || true
done

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in dac5d21. Each layer is now checked with sha256sum against the digest its manifest names before it is extracted. A mismatch or a non-sha256 digest stops the install.


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FGcrXbknJ2JWPDzNoNhPCw
@matt-edmondson
matt-edmondson force-pushed the claude/cloud-session-setup-luxi33 branch from df20d19 to dac5d21 Compare October 20, 2026 12:06
dotnet-install.sh is fetched and run with nothing to verify it against, and
its host is blocked in cloud sessions anyway, so the installer now always
takes the MCR route, whose layers are checked against their digests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FGcrXbknJ2JWPDzNoNhPCw
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Copy Markdown
Contributor Author

SonarCloud's quality gate fails on 68131b1 with "C Security Rating on New Code". The only new code in this PR is the cloud-session hook scripts under .claude/hooks/. ktsu-dev/Sdk#80, ktsu-dev/SourceGeneratorToolkit#52, ktsu-dev/Navigation#91, ktsu-dev/UndoRedo#156 and ktsu-dev/Semantics#483 report the same finding on identical scripts.

I can't see which rule fired. sonarcloud.io is blocked from the session that opened this PR, and the check run has no annotations, only the summary. The finding is listed on the issues dashboard. Once someone shares the rule and line, I'll push the fix here and to the other PRs.


Generated by Claude Code

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.

3 participants