Skip to content

Harden LogSight-AI for production readiness#5

Merged
CoreyLeath-code merged 35 commits into
mainfrom
agent/production-hardening
Jul 17, 2026
Merged

Harden LogSight-AI for production readiness#5
CoreyLeath-code merged 35 commits into
mainfrom
agent/production-hardening

Conversation

@CoreyLeath-code

@CoreyLeath-code CoreyLeath-code commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Production-hardens the supported LogSight-AI CLI and replaces false-green automation with enforceable quality, security, packaging, benchmark, and container gates.

What changed

  • adds a documented production-readiness audit, deployment guide, benchmark methodology, security policy, and MIT license
  • raises core test coverage to 95% with a 90% CI floor and adds negative, edge-case, CLI integration, and performance tests
  • validates anomaly thresholds, spike thresholds, and window sizes at library and CLI boundaries
  • removes unused NumPy/scikit-learn runtime dependencies and uses standard-library statistics
  • consolidates CI into fail-closed Ruff, mypy, pytest, coverage, package, container, Bandit, pip-audit, license, SBOM, secret-scan, and benchmark jobs
  • adds CodeQL and Dependabot
  • hardens the container/Compose contract with a non-root user, health check, dropped capabilities, read-only filesystem, and resource limits
  • replaces unsupported or fabricated README claims with measured results and explicit prototype boundaries
  • removes workflows that targeted nonexistent paths or swallowed failures

Why

The previous repository could report success after failed tests, security scans, and benchmarks; advertised unsupported deployment services; and accepted invalid analysis parameters. This change makes the supported local CLI contract reproducible and reviewable.

Validation

  • 50 tests passing
  • 95.28% core package coverage
  • Ruff passing
  • strict mypy passing
  • Bandit: zero findings
  • source distribution and wheel build successfully
  • local 1,000-line benchmark: approximately 10.5 ms median

Docker image execution remains delegated to CI because the local Docker daemon was unavailable.

Summary by CodeRabbit

  • New Features
    • Added periodic container health checks and a hardened, resource-limited deployment setup.
    • Improved log parsing to accept any iterable input (including streaming/stdin).
    • Added stricter CLI validation for analysis thresholds and error-spike settings.
    • Reduced runtime dependencies for a lighter install.
  • Bug Fixes
    • Validation now rejects invalid anomaly/error-rate parameters (e.g., non-finite thresholds, out-of-range spike thresholds).
  • Documentation
    • Added SECURITY policy and production/audit/deployment/benchmarking docs; rewrote README for local-first CLI usage; added benchmark report.
  • Chores
    • Consolidated and expanded CI automation (quality checks, security scanning/inventories, CodeQL, benchmarks).

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ebffa67e-7db8-4bf3-ae27-400782ba25aa

📥 Commits

Reviewing files that changed from the base of the PR and between 9baabeb and 18b0222.

📒 Files selected for processing (6)
  • .github/workflows/ci.yml
  • agents/guards.py
  • agents/orchestrator.py
  • app.py
  • demo.app.py
  • log_simulator.py

📝 Walkthrough

Walkthrough

The change broadens parser input handling, removes NumPy from anomaly calculations, adds validation and tests, modernizes packaging, replaces CI checks with quality/security/package/benchmark jobs, hardens container execution, and adds project, deployment, benchmarking, licensing, and security documentation.

Changes

Logsight CLI and delivery controls

Layer / File(s) Summary
Parsing and anomaly validation
logsight/parser.py, logsight/analyzer.py, tests/test_parser.py, tests/test_analyzer.py
Parsing accepts iterables, anomaly calculations use standard-library statistics, invalid parameters are rejected, and parser/analyzer tests are expanded.
CLI validation and output
logsight/cli.py, tests/test_cli.py
Click options enforce valid thresholds and windows, output formatting changes, and analyze/stdin behavior is tested.
Packaging and developer tooling
agents/state.py, pyproject.toml, requirements*.txt
Python metadata, development extras, requirements, type annotations, coverage, Ruff, MyPy, and Bandit configuration are updated.
CI, security, and container automation
.github/dependabot.yml, .github/workflows/*, Dockerfile, docker-compose.yml, tests/test_benchmarks.py
CI adds quality, packaging, security, and benchmark jobs; CodeQL and Dependabot are configured; container health and runtime hardening are added; deterministic benchmarking is introduced.
Documentation and project policy
README.md, SECURITY.md, LICENSE, docs/*, benchmarks/benchmark_report.md
Project usage, deployment, benchmarking, audit, security, licensing, and baseline benchmark documentation are added or rewritten.
Demonstration and orchestration cleanup
agents/guards.py, agents/orchestrator.py, app.py, demo.app.py, log_simulator.py
Demonstration interfaces, orchestration formatting, circuit-breaker spacing, and simulator formatting are updated without changing core processing behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: dependencies, github_actions

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main goal of hardening LogSight-AI for production readiness.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/production-hardening

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

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@CoreyLeath-code
CoreyLeath-code merged commit a185768 into main Jul 17, 2026
6 of 7 checks passed

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9baabebeae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/ci.yml
Comment on lines +26 to +27
- run: ruff format --check .
- run: ruff check .

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Limit Ruff CI to files that actually pass

With this workflow change, both Ruff steps scan the entire repository, but the retained prototype files are not Ruff-clean. I ran the exact commands from the job: ruff format --check . wants to reformat agents/guards.py, agents/orchestrator.py, app.py, demo.app.py, and log_simulator.py, and ruff check . fails on existing import/whitespace/E701/F401 issues in those same demo/prototype areas. Since this job runs on every push/PR, CI is blocked until those files are formatted/fixed or the Ruff scope is limited to the supported package/tests.

Useful? React with 👍 / 👎.

Comment thread .github/workflows/ci.yml
python-version: "3.11"
- run: pip install build
- run: python -m build
- run: docker build --tag logsight-ai:${{ github.sha }} .

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Copy README before building the Docker wheel

The new container job now makes the existing Dockerfile part of required CI, but that builder stage only copies pyproject.toml, requirements.txt, and logsight/ before running python -m build; pyproject.toml declares readme = "README.md", so metadata generation inside the Docker build context is missing the README that exists at the repository root. In the package-and-container workflow I inspected, this docker build step will fail even though python -m build at the checkout root can see the file; copy README.md (and any other declared metadata files) into the builder stage before building the wheel.

Useful? React with 👍 / 👎.

@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: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Line 20: Add persist-credentials: false to every actions/checkout@v4 step in
the workflow. Retain fetch-depth: 0 only on the security job’s checkout step,
removing it from other checkout steps while preserving their remaining
configuration.
- Around line 21-25: Update the CI quality job’s Python setup matrix to run both
Python 3.10 and 3.11, preserving the existing pip cache and development
dependency installation so the declared minimum version is validated.

In `@logsight/cli.py`:
- Line 60: Update the float option definitions in the CLI, including the one
using click.FloatRange(min=0), to use a shared validator that rejects NaN and
positive or negative infinity at Click parsing time. Ensure invalid non-finite
values become Click usage errors while preserving the existing range constraints
for finite inputs and applying the validator to unbounded threshold options as
well.

In `@README.md`:
- Around line 24-31: Update the README setup instructions around the
virtual-environment activation command by separating Unix/macOS and Windows
examples into distinct shell snippets. Include the existing Unix source command,
Windows Command Prompt activation, and PowerShell activation syntax, while
keeping the subsequent installation and Logsight usage commands clear and
unchanged.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2dd2eca5-69f2-486c-b4aa-d47f7a867641

📥 Commits

Reviewing files that changed from the base of the PR and between ce9bd2f and 9baabeb.

📒 Files selected for processing (29)
  • .github/dependabot.yml
  • .github/workflows/benchmarks.yml
  • .github/workflows/ci-cd.yml
  • .github/workflows/ci.yml
  • .github/workflows/codeql.yml
  • .github/workflows/data-validation.yml
  • .github/workflows/release.yml
  • .github/workflows/sast.yml
  • .github/workflows/security.yml
  • Dockerfile
  • LICENSE
  • README.md
  • SECURITY.md
  • agents/state.py
  • benchmarks/benchmark_report.md
  • docker-compose.yml
  • docs/AUDIT.md
  • docs/BENCHMARKING.md
  • docs/DEPLOYMENT.md
  • logsight/analyzer.py
  • logsight/cli.py
  • logsight/parser.py
  • pyproject.toml
  • requirements-dev.txt
  • requirements.txt
  • tests/test_analyzer.py
  • tests/test_benchmarks.py
  • tests/test_cli.py
  • tests/test_parser.py
💤 Files with no reviewable changes (6)
  • .github/workflows/sast.yml
  • .github/workflows/benchmarks.yml
  • .github/workflows/security.yml
  • .github/workflows/data-validation.yml
  • .github/workflows/release.yml
  • .github/workflows/ci-cd.yml

Comment thread .github/workflows/ci.yml
steps:
- name: ⬇️ Checkout Repository
uses: actions/checkout@v4
- uses: actions/checkout@v4

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the workflow around all checkout steps.
git ls-files .github/workflows/ci.yml
echo "----"
nl -ba .github/workflows/ci.yml | sed -n '1,140p'
echo "----"
rg -n "actions/checkout@v4|persist-credentials|fetch-depth" .github/workflows/ci.yml

Repository: CoreyLeath-code/LogSight-AI

Length of output: 235


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- file ----"
awk '{printf "%5d  %s\n", NR, $0}' .github/workflows/ci.yml | sed -n '1,160p'
echo "---- matches ----"
rg -n "actions/checkout@v4|persist-credentials|fetch-depth" .github/workflows/ci.yml

Repository: CoreyLeath-code/LogSight-AI

Length of output: 3436


Disable persisted checkout credentials. These jobs run PR-controlled code, so leaving the default checkout token in git config lets that code read it. Set persist-credentials: false on every actions/checkout@v4 step, and keep fetch-depth: 0 only in the security job.

🧰 Tools
🪛 zizmor (1.26.1)

[warning] 20-20: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml at line 20, Add persist-credentials: false to every
actions/checkout@v4 step in the workflow. Retain fetch-depth: 0 only on the
security job’s checkout step, removing it from other checkout steps while
preserving their remaining configuration.

Source: Linters/SAST tools

Comment thread .github/workflows/ci.yml Outdated
Comment on lines +21 to +25
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- run: python -m pip install --upgrade pip && pip install -e ".[dev]"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n 'requires-python|python_version|python-version|FROM python:' \
  pyproject.toml .github/workflows/ci.yml Dockerfile

Repository: CoreyLeath-code/LogSight-AI

Length of output: 589


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n--- .github/workflows/ci.yml ---\n'
cat -n .github/workflows/ci.yml

printf '\n--- pyproject.toml (relevant lines) ---\n'
cat -n pyproject.toml | sed -n '1,120p'

printf '\n--- Dockerfile ---\n'
cat -n Dockerfile

Repository: CoreyLeath-code/LogSight-AI

Length of output: 7308


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- workflow checkout usage ---'
rg -n 'actions/checkout@|persist-credentials|python-version|python-version:' .github/workflows

echo
echo '--- any 3.10 references ---'
rg -n '3\.10|>=3\.10|python_version' .github pyproject.toml Dockerfile README.md

Repository: CoreyLeath-code/LogSight-AI

Length of output: 1040


Add Python 3.10 to CI pyproject.toml declares >=3.10, but this job only runs 3.11. Run the quality job on 3.10 too so minimum-version regressions are caught.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 21 - 25, Update the CI quality job’s
Python setup matrix to run both Python 3.10 and 3.11, preserving the existing
pip cache and development dependency installation so the declared minimum
version is validated.

Comment thread logsight/cli.py
"--threshold",
"-t",
default=2.5,
type=click.FloatRange(min=0),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== logsight/cli.py (relevant sections) ==\n'
cat -n logsight/cli.py | sed -n '1,220p'

printf '\n== search for float options and downstream use ==\n'
rg -n "FloatRange|detect_anomalies|error_rate_spike|nan|inf|finite|math\.isfinite" logsight -S

printf '\n== locate tests for CLI validation ==\n'
rg -n "click\.CliRunner|CliRunner|invalid value|FloatRange|nan|inf|detect_anomalies|error_rate_spike" tests logsight -S

Repository: CoreyLeath-code/LogSight-AI

Length of output: 10487


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== logsight/analyzer.py (relevant sections) ==\n'
cat -n logsight/analyzer.py | sed -n '1,220p'

printf '\n== tests/test_cli.py ==\n'
cat -n tests/test_cli.py | sed -n '1,220p'

printf '\n== click FloatRange behavior probe ==\n'
python3 - <<'PY'
import click
from click.testing import CliRunner

`@click.command`()
`@click.option`("--x", type=click.FloatRange(min=0), default=2.5)
def cmd(x):
    click.echo(repr(x))

runner = CliRunner()
for arg in ["inf", "-inf", "nan", "1.5", "0", "-1"]:
    result = runner.invoke(cmd, ["--x", arg])
    print(arg, "=>", "OK" if result.exit_code == 0 else f"ERR {result.exit_code}", repr(result.output.strip()))
PY

Repository: CoreyLeath-code/LogSight-AI

Length of output: 9187


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import click
from click.testing import CliRunner

`@click.command`()
`@click.option`("--x", type=click.FloatRange(min=0, max=1))
def cmd(x):
    click.echo(repr(x))

runner = CliRunner()
for arg in ["inf", "-inf", "nan", "1.5", "1", "0"]:
    result = runner.invoke(cmd, ["--x", arg])
    status = "OK" if result.exit_code == 0 else f"ERR {result.exit_code}"
    print(f"{arg:>4} => {status} | {result.output.strip()!r}")
PY

Repository: CoreyLeath-code/LogSight-AI

Length of output: 628


Reject non-finite float inputs at the Click boundary. FloatRange still lets nan through, and the unbounded threshold options also accept inf; both end up as raw ValueErrors in detect_anomalies/error_rate_spike instead of Click usage errors. Add a shared finite-value validator for the float options here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@logsight/cli.py` at line 60, Update the float option definitions in the CLI,
including the one using click.FloatRange(min=0), to use a shared validator that
rejects NaN and positive or negative infinity at Click parsing time. Ensure
invalid non-finite values become Click usage errors while preserving the
existing range constraints for finite inputs and applying the validator to
unbounded threshold options as well.

Comment thread README.md
Comment on lines +24 to +31
```bash
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .
logsight health
logsight analyze application.log
cat application.log | logsight stdin
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Separate Unix and Windows activation commands.

The code block uses source .venv/bin/activate while only commenting on the Windows path; Windows users cannot paste this command as written. Provide separate shell snippets, including PowerShell activation syntax.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` around lines 24 - 31, Update the README setup instructions around
the virtual-environment activation command by separating Unix/macOS and Windows
examples into distinct shell snippets. Include the existing Unix source command,
Windows Command Prompt activation, and PowerShell activation syntax, while
keeping the subsequent installation and Logsight usage commands clear and
unchanged.

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