Skip to content

Conversation

@thoraxe
Copy link
Contributor

@thoraxe thoraxe commented Sep 11, 2025

Description

Adds a CLAUDE.md (read by default) so that Claude understands the coding, testing, and other practices for working with this project.

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement

Related Tickets & Documents

N/A

Checklist before requesting a review

N/A

Testing

N/A

Summary by CodeRabbit

  • Documentation
    • Added the Lightspeed Core Stack Development Guide as a centralized developer reference.
    • Covers architecture overview, project layout, configuration patterns, and coding standards.
    • Details typing, Pydantic configuration, error handling, logging, and function/class design guidance.
    • Outlines testing strategy (unit, integration, E2E), fixtures, and coverage targets.
    • Specifies QA checks: formatting, linting, typing, security scanning, and secret management.
    • Lists key dependencies, supported Python versions, and recommended development/workflow commands.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 11, 2025

Walkthrough

Adds CLAUDE.md, a new Lightspeed Core Stack development guide documenting architecture, environment/setup, coding standards, configuration/typing, error handling, testing, QA, dependencies, and development workflow. No code, API, or exported/public entity changes.

Changes

Cohort / File(s) Summary
Documentation
CLAUDE.md
New comprehensive development guide for the Lightspeed Core Stack covering project overview, development environment, recommended project structure and patterns, coding standards, configuration/typing, function/class design, error handling and logging, testing strategies, QA/security checks, dependencies, and development workflow.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested reviewers

  • tisnik

Poem

A rabbit taps keys with a satisfied grin,
“Guides in the garden—now let’s hop in!”
Paths well-marked, no code to mend,
Checklists bloom from start to end.
With docs this neat, I twitch my nose—
Onward, devs! The roadmap grows. 🥕

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "adds instructions for Claude" accurately reflects the primary change in the changeset — the addition of a CLAUDE.md with coding, testing, and development guidance — and is concise and focused on the main change. It is not misleading or overly broad and therefore summarizes the main intent of the PR. Minor stylistic issues (lowercase wording and slightly generic phrasing) do not make the title incorrect.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (7)
CLAUDE.md (7)

16-16: Fix MD040: add a language to the fenced code block (Project Structure).

Specify a language to satisfy markdownlint.

-```
+```text

74-74: Fix MD040: add a language to the fenced code block (Test Structure).

Specify a language to satisfy markdownlint.

-```
+```text

35-35: Make the import example actually “relative.”

The example currently shows an absolute import; use a relative import per the guideline.

-- Use relative imports within modules: `from auth import get_auth_dependency`
+- Use relative imports within modules: `from .auth import get_auth_dependency`

66-70: Prefer typing.Self on Python ≥3.12; fall back to typing_extensions only for older versions.

Keeps guidance aligned with the stated Python versions.

-- Use `typing_extensions.Self` for model validators
+- Use `typing.Self` (Python ≥3.12). Use `typing_extensions.Self` only if supporting ≤3.11.
 - Union types: `str | int` (modern syntax)
- - Optional: `Optional[Type]` or `Type | None`
+ - Optional: prefer `Type | None` for consistency

41-45: Clarify Pydantic v2 configuration pattern.

If ConfigurationBase is project-specific, call that out; otherwise show the v2-native pattern with ConfigDict.

-- All config uses Pydantic models extending `ConfigurationBase`
-- Base class sets `extra="forbid"` to reject unknown fields
+- All config uses Pydantic v2 `BaseModel` (or project `ConfigurationBase`) with
+  `model_config = ConfigDict(extra="forbid")` to reject unknown fields
+- Use `@model_validator` for custom validation

Would you like me to update this section with a short code snippet showing ConfigDict?


131-137: Avoid pinning versions in docs; source-of-truth should be pyproject.toml.

Prevents drift; keep this section stable.

-- **FastAPI**: Web framework (`>=0.115.12`)
-- **Llama Stack**: AI integration (`==0.2.19`)
- - **Pydantic**: Data validation/serialization
-- **SQLAlchemy**: Database ORM (`>=2.0.42`)
-- **Kubernetes**: K8s auth integration (`>=30.1.0`)
+- Refer to `pyproject.toml` for authoritative versions/constraints.
+- **FastAPI**: Web framework
+- **Llama Stack**: AI integration
+- **Pydantic**: Data validation/serialization
+- **SQLAlchemy**: Database ORM
+- **Kubernetes**: K8s auth integration

126-130: Optional: add secret scanning to QA.

Recommend pre-commit hooks for gitleaks or detect-secrets to enforce “never commit secrets.”

I can propose a minimal pre-commit config if you want it included.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63996a6 and 255f8c6.

📒 Files selected for processing (1)
  • CLAUDE.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
CLAUDE.md

16-16: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


74-74: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build-pr
  • GitHub Check: e2e_tests
🔇 Additional comments (5)
CLAUDE.md (5)

1-144: Solid addition—clear, actionable guidance.

Overall looks good; the above are minor doc nits and consistency checks.


60-64: Use APIConnectionError from llama_stack_client (explicit import)

Update CLAUDE.md (lines 60–64) to reference llama_stack_client.APIConnectionError and show the import example: from llama_stack_client import APIConnectionError.


139-140: dev and llslibdev groups exist in pyproject.toml — no change required.
Both groups are defined (pyproject.toml: dev at line 92; llslibdev at line 114).


118-125: Update CLAUDE.md to match Makefile 'verify' target

  • Makefile's verify target invokes these targets: black (uv run black --check .), pylint (uv run pylint src tests), pyright (uv run pyright src), ruff (uv run ruff check . --per-file-ignores=tests/:S101 --per-file-ignores=scripts/:S101), docstyle (uv run pydocstyle -v src), check-types → mypy (uv run mypy --explicit-package-bases --disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs --ignore-missing-imports --disable-error-code attr-defined src/).

  • Replace the ambiguous "docstyle"/"check-types" wording in CLAUDE.md (lines 118–125) with the exact target names above and remove the claim that pyright excludes src/auth/k8s.py (no such exclusion in Makefile). Optionally mention that the format target runs uv run black . and uv run ruff check . --fix.


7-12: No change required — CLAUDE.md matches repo configuration

pyproject.toml has requires-python = ">=3.12,<3.14" and GitHub Actions run 3.12 / 3.13 matrices, so the CLAUDE.md claim (3.12–3.13; 3.14 not supported) is consistent.

CLAUDE.md Outdated
### Coding Standards

#### Imports & Dependencies
- Use relative imports within modules: `from auth import get_auth_dependency`
Copy link
Contributor

Choose a reason for hiding this comment

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

relative imports starts with . or ..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch - fixed with d4af8e0

CLAUDE.md Outdated
#### Configuration
- All config uses Pydantic models extending `ConfigurationBase`
- Base class sets `extra="forbid"` to reject unknown fields
- Use `@model_validator` for custom validation
Copy link
Contributor

Choose a reason for hiding this comment

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

@field_validator can also be used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added in d4af8e0

CLAUDE.md Outdated
#### Error Handling
- Use FastAPI `HTTPException` with appropriate status codes
- Handle `APIConnectionError` from Llama Stack
- Logging: `import logging` and use module logger
Copy link
Contributor

Choose a reason for hiding this comment

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

prob. also mention which loglevel to use in the new code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a logging section specifically with d4af8e0

- Use `typing_extensions.Self` for model validators
- Union types: `str | int` (modern syntax)
- Optional: `Optional[Type]` or `Type | None`

Copy link
Contributor

Choose a reason for hiding this comment

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

instructions for modules, functions, classes, and methods docstrings...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this the exhaustive list, or are there other items? CLAUDE.md is automatically read by CLAUDE, so if you intend to fully document coding practices for "everything" you'll need a list of "everything".

I'll try to extract specifics for what you listed, but if there's anything else, can you list it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

d4af8e0
addresses the listed items

return mock_client, mock_agent
```
- **Auth Mock**: `MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token")`
- **Coverage**: Unit tests require 60% coverage, integration 10%
Copy link
Contributor

Choose a reason for hiding this comment

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

  • instruction to use pytest everywhere, forbid to use unittest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CLAUDE.md Outdated
- Use environment variables for sensitive data

## Key Dependencies
- **FastAPI**: Web framework (`>=0.115.12`)
Copy link
Contributor

Choose a reason for hiding this comment

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

dunno about versions there, prob. instruct to read from pyproject.toml?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ya, they might change, and unless we auto update the claude.md all the time, this may get stale.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (7)
CLAUDE.md (7)

16-30: Add language to fenced code block (markdownlint MD040).

Mark the project tree as text for proper highlighting.

-```
+```text
 src/
 ├── app/                    # FastAPI application
 │   ├── endpoints/         # REST API endpoints
 │   └── main.py           # Application entry point
 ├── auth/                  # Authentication modules (k8s, jwk, noop)
 ├── authorization/         # Authorization middleware & resolvers
 ├── models/               # Pydantic models
 │   ├── config.py         # Configuration classes
 │   ├── requests.py       # Request models
 │   └── responses.py      # Response models
 ├── utils/                # Utility functions
 ├── client.py             # Llama Stack client wrapper
 └── configuration.py      # Config management
-```
+```

111-117: Add language to fenced code block (markdownlint MD040).

Mark the tests tree as text.

-```
+```text
 tests/
 ├── unit/                 # Unit tests (pytest)
 ├── integration/          # Integration tests
 └── e2e/                 # End-to-end tests (behave)
     └── features/        # Gherkin feature files
-```
+```

99-106: Replace bare URL with descriptive link (markdownlint MD034).

Improves readability and satisfies linters.

-- Follow Google Python docstring conventions: https://google.github.io/styleguide/pyguide.html
+- Follow Google Python docstring conventions: [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)

56-59: Clarify Self typing guidance for Python versions.

Prefer typing.Self on 3.11+, fall back to typing_extensions on older versions.

-  - Use `typing_extensions.Self` for model validators
+  - Prefer `typing.Self` (Python 3.11+); otherwise use `typing_extensions.Self` for model validators

10-12: Align “verify” tool list with Linting Tools; choose one primary type checker.

“verify” mentions “docstyle, check-types” while Linting Tools list pydocstyle + both pyright and mypy. Recommend naming the exact tools consistently and documenting which type checker is authoritative to avoid conflicting results.


161-167: Document the canonical type checker and where it’s configured.

Running both pyright and mypy can be redundant; if both are required, state their scopes (e.g., pyright for editors, mypy in CI) and link to the config sections.


152-159: Consider adding pre-commit hook instructions.

Eases consistent formatting/linting locally: pre-commit with black, ruff, pydocstyle, bandit.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 255f8c6 and d4af8e0.

📒 Files selected for processing (1)
  • CLAUDE.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
CLAUDE.md

16-16: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


99-99: Bare URL used

(MD034, no-bare-urls)


111-111: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (4)
CLAUDE.md (4)

145-150: Makefile targets verified — no action needed.
Makefile defines test-unit, test-integration, test-e2e, format, and verify targets; docs match.


182-183: uv groups 'dev' and 'llslibdev' are present in pyproject.toml.
Found dev = [ at line 92 and llslibdev = [ at line 114 in pyproject.toml.


75-77: Use the llama_stack_client concrete exception classes

Replace "APIConnectionError" in CLAUDE.md (lines 75–77) with the actual client exceptions — e.g. llama_stack_client.APIConnectionError (connection issues); also mention llama_stack_client.APIStatusError and llama_stack_client.RateLimitError (and the status-specific errors like BadRequestError/AuthenticationError/NotFoundError) as appropriate. (github.com)


48-53: ConfigurationBase exists and enforces extra="forbid"
ConfigurationBase is defined in src/models/config.py and sets model_config = ConfigDict(extra="forbid").

@thoraxe
Copy link
Contributor Author

thoraxe commented Sep 18, 2025

@tisnik I made all the requested changes here.

Copy link
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

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

LGTM

@tisnik tisnik merged commit db21c10 into lightspeed-core:main Sep 18, 2025
19 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 10, 2025
15 tasks
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