Skip to content

fix: kube stream grant end, web stream load slot, setup.sh on old bash, CI coverage gaps - #314

Merged
jfcmartins merged 5 commits into
mainfrom
claude/focused-thompson-2ljdpz
Nov 12, 2026
Merged

jfcmartins merged 5 commits into
mainfrom
claude/focused-thompson-2ljdpz

Conversation

@jfcmartins

Copy link
Copy Markdown
Collaborator

What and why

Five small, independent fixes from a repository review. They don't overlap the open PRs (#304, #300, #276). One commit each:

  1. fix(worker): end upgraded kube streams when their access grant ends.
    • Before: the exec/attach/port-forward pump (kube/pump.rs) checked the session deadline and locks but not grant_ended. must_stop does check it for streaming responses (kube/serve.rs).
    • Now both use one function, Admitted::stop_reason (kube/mod.rs), and the unused expires argument is gone.
    • The proxy's revocation watch already ended these streams, so this brings back the worker's own check (defense in depth).
  2. fix(proxy): hold a web stream's worker load slot until the stream ends.
    • Before: open_web_stream dropped its SessionSlot on return, so a long-lived WebSocket stopped counting toward the worker's load. That under-counted p2c placement, /tunnels and the load reported to peers.
    • Now the slot moves into the relay task, as kube.rs already does.
  3. fix(compose): guard the empty stacks array in setup.sh.
    • Before: stack_policy_files "$root" "${stacks[@]}" fails under set -u on bash older than 4.4 (macOS /bin/bash 3.2) when no stacks are chosen (--stacks none).
    • Now it uses the guarded ${stacks[@]+"${stacks[@]}"} form every other call in the file uses.
  4. ci(deps): Dependabot watches all nine Terraform directories. Before, it watched three. The other six are the ones infra.yml validates, and each has a required_providers block.
  5. ci: rust.yml runs for excluded files that the build or tests read.
    • These files are under excluded paths (docs/, assets/, .github/) but are read anyway:
      • docs/cli-reference.md, docs/policy-schema/** and docs/guides/audit-ocsf.md are compared by tests.
      • assets/logo-mark.svg is pulled in by include_str! in limen-cli.
      • .github/workflows/release.yml is checked by scripts/check-versions.sh.
    • Before, a PR that touched only these files started no Rust CI.

Related: maintenance; no phase work.

How it was verified

  • cargo fmt --all and cargo clippy --workspace --all-targets --all-features --locked -- -D warnings are clean.
    • protoc came from Ubuntu's protobuf-compiler 3.21, not the 36.2 that mise.toml pins.
  • cargo test -p limen-proxy -p limen-worker passes (363 worker lib tests and the proxy suites).
    • That includes four new kube::tests for stop_reason: running, deadline, grant revoked or expired, and locked user.
  • bash -n deploy/compose/setup.sh passes.
  • shellcheck 0.10 (-S warning) shows only the existing SC2154 for compose.
  • On bash 5, an empty and a non-empty array both expand correctly in the guarded form.
  • rust.yml and dependabot.yml parse as YAML.

Not verified

  • I had no bash 3.2 to run setup.sh on.
  • actionlint and gitleaks weren't run (no mise here). CI runs actionlint.
  • No integration, e2e or demo runs; the compose stack wasn't started.
  • No test covers the web-stream slot fix. Proxy unit tests have no harness for a live tunnel, so it's checked only by reading the code against the kube path.

Review guide

  • Start with crates/limen-worker/src/kube/mod.rs (stop_reason). The checks run in the same order as the old must_stop: deadline, grant, then locks.

Checklist

  • Tests added or updated; cargo fmt and cargo clippy ... -D warnings clean
  • Docs updated: n/a
  • Phase work: n/a
  • Secrets stay out of logs; mTLS and fail-closed audit intact (nothing touched there)
  • New dependency: n/a
  • New entry point or data store: n/a
  • Commits are conventional, small and focused

Compatibility and rollback

None. Revert any commit on its own.


Generated by Claude Code

The exec, attach and port-forward pump checked the session deadline and
locks but not grant_ended, unlike must_stop for streaming responses. Both
now share Admitted::stop_reason, which is unit-tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEiXYYviUmZxCvQoG6xkeL
open_web_stream dropped its SessionSlot on return, so a long-lived
WebSocket stopped counting toward the worker's load while it ran. The
slot now moves into the relay task, as the kube path already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEiXYYviUmZxCvQoG6xkeL
With --stacks none, bash before 4.4 (macOS /bin/bash) fails on an empty
"${stacks[@]}" under set -u. Use the guarded form the other calls use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEiXYYviUmZxCvQoG6xkeL
Six of the nine directories infra.yml validates had required_providers
blocks Dependabot never checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEiXYYviUmZxCvQoG6xkeL
docs/cli-reference.md, docs/policy-schema, docs/guides/audit-ocsf.md,
assets/logo-mark.svg and release.yml are read by tests, include_str! or
check-versions.sh, but the path filter excluded them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEiXYYviUmZxCvQoG6xkeL
@jfcmartins
jfcmartins marked this pull request as ready for review November 12, 2026 10:41

Copy link
Copy Markdown
Collaborator Author

Tests (Linux arm64) failed on a_replay_that_cannot_be_audited_does_not_run (crates/limen-control-plane/tests/policy_replay.rs:359). The same test fails the same way on main: rust.yml runs 43069928081 (#307, arm64) and 43102504414 (#312, x64). This PR doesn't touch the control plane, so this failure isn't from this PR.

Likely cause (from the log; I haven't reproduced it, since I had no PostgreSQL here):

  • The test fills the 6000-byte spool with logins until one is refused. That stopped at 5502 bytes.
  • The replay's pre-check event is smaller than a login event, so it still fit. ApplyPolicy then answered Ok.
  • Only the replay's best-effort result event hit the full spool (5978 of 6000): WARN could not record the result of a policy replay.

So whether the replay is refused depends on how many bytes the logins left free, not on the replay itself. A possible fix, for the owner to choose:

  • Keep filling with an event no larger than the replay's pre-check event.
  • Or have the replay reserve or check the spool space it needs before it runs.

I've left it unchanged here, because changing the audit fail-closed behaviour needs the owner's call.


Generated by Claude Code

@jfcmartins
jfcmartins merged commit 7157b3b into main Nov 12, 2026
22 of 23 checks passed
@jfcmartins
jfcmartins deleted the claude/focused-thompson-2ljdpz branch November 12, 2026 11:22
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