rw-sysstable 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. rw_sysstable-0.2.0/.dockerignore +61 -0
  2. rw_sysstable-0.2.0/.github/workflows/lint.yml +39 -0
  3. rw_sysstable-0.2.0/.github/workflows/pre-commit.yml +21 -0
  4. rw_sysstable-0.2.0/.github/workflows/publish.yml +63 -0
  5. rw_sysstable-0.2.0/.github/workflows/smoke-test.yml +69 -0
  6. rw_sysstable-0.2.0/.github/workflows/tests.yml +60 -0
  7. rw_sysstable-0.2.0/.gitignore +31 -0
  8. rw_sysstable-0.2.0/.pre-commit-config.yaml +18 -0
  9. rw_sysstable-0.2.0/.python-version +1 -0
  10. rw_sysstable-0.2.0/CHANGELOG.md +84 -0
  11. rw_sysstable-0.2.0/CODE_OF_CONDUCT.md +53 -0
  12. rw_sysstable-0.2.0/CONTRIBUTING.md +85 -0
  13. rw_sysstable-0.2.0/Dockerfile +32 -0
  14. rw_sysstable-0.2.0/LICENSE +21 -0
  15. rw_sysstable-0.2.0/MANIFEST.in +5 -0
  16. rw_sysstable-0.2.0/Makefile +108 -0
  17. rw_sysstable-0.2.0/PKG-INFO +321 -0
  18. rw_sysstable-0.2.0/README.md +284 -0
  19. rw_sysstable-0.2.0/SECURITY.md +39 -0
  20. rw_sysstable-0.2.0/docker-compose.yml +17 -0
  21. rw_sysstable-0.2.0/docs/SESSION_STATE.md +55 -0
  22. rw_sysstable-0.2.0/docs/audits/comprehensive-audit-2026-07-02.md +322 -0
  23. rw_sysstable-0.2.0/docs/audits/final-v0.2.0-audit.md +113 -0
  24. rw_sysstable-0.2.0/docs/audits/phase2-audit-2026-07-03.md +70 -0
  25. rw_sysstable-0.2.0/docs/deployment.md +253 -0
  26. rw_sysstable-0.2.0/docs/plan-critical-memory-resolution.md +407 -0
  27. rw_sysstable-0.2.0/docs/plugin-install.md +108 -0
  28. rw_sysstable-0.2.0/docs/spec-critical-memory-resolution.md +569 -0
  29. rw_sysstable-0.2.0/docs/spec.md +99 -0
  30. rw_sysstable-0.2.0/docs/sysstable.service +14 -0
  31. rw_sysstable-0.2.0/hermes-plugin/rapidwebs-sysstable/__init__.py +199 -0
  32. rw_sysstable-0.2.0/hermes-plugin/rapidwebs-sysstable/install.sh +99 -0
  33. rw_sysstable-0.2.0/hermes-plugin/rapidwebs-sysstable/plugin.yaml +16 -0
  34. rw_sysstable-0.2.0/install.sh +144 -0
  35. rw_sysstable-0.2.0/pyproject.toml +82 -0
  36. rw_sysstable-0.2.0/src/ast_tools/config/__init__.py +0 -0
  37. rw_sysstable-0.2.0/src/ast_tools/config/loader.py +104 -0
  38. rw_sysstable-0.2.0/src/ast_tools/config/tokens_schema.py +49 -0
  39. rw_sysstable-0.2.0/src/ast_tools/config/validate.py +28 -0
  40. rw_sysstable-0.2.0/src/sysstable/__init__.py +3 -0
  41. rw_sysstable-0.2.0/src/sysstable/__main__.py +6 -0
  42. rw_sysstable-0.2.0/src/sysstable/cli.py +468 -0
  43. rw_sysstable-0.2.0/src/sysstable/collector.py +258 -0
  44. rw_sysstable-0.2.0/src/sysstable/config.py +105 -0
  45. rw_sysstable-0.2.0/src/sysstable/daemon.py +238 -0
  46. rw_sysstable-0.2.0/src/sysstable/database.py +241 -0
  47. rw_sysstable-0.2.0/src/sysstable/events.py +96 -0
  48. rw_sysstable-0.2.0/src/sysstable/process_watch.py +498 -0
  49. rw_sysstable-0.2.0/src/sysstable/resolver.py +380 -0
  50. rw_sysstable-0.2.0/src/sysstable/socketd.py +123 -0
  51. rw_sysstable-0.2.0/src/sysstable/state_machine.py +154 -0
  52. rw_sysstable-0.2.0/src/sysstable/systemd_notify.py +68 -0
  53. rw_sysstable-0.2.0/src/sysstable/thresholds.py +121 -0
  54. rw_sysstable-0.2.0/src/sysstable/utils.py +26 -0
  55. rw_sysstable-0.2.0/tests/test_core.py +393 -0
  56. rw_sysstable-0.2.0/tests/test_integration.py +213 -0
  57. rw_sysstable-0.2.0/tests/test_process_watch.py +291 -0
  58. rw_sysstable-0.2.0/tests/test_resolver.py +132 -0
  59. rw_sysstable-0.2.0/tests/test_state_machine.py +99 -0
  60. rw_sysstable-0.2.0/uv.lock +1281 -0
@@ -0,0 +1,61 @@
1
+ # Git
2
+ .git/
3
+ .gitignore
4
+ .gitattributes
5
+
6
+ # Virtual environments
7
+ .venv/
8
+ venv/
9
+ env/
10
+
11
+ # Python
12
+ __pycache__/
13
+ *.py[cod]
14
+ *.egg-info/
15
+ build/
16
+ dist/
17
+
18
+ # Project docs (not needed at runtime)
19
+ docs/
20
+ *.md
21
+ CHANGELOG.md
22
+ LICENSE
23
+ CODE_OF_CONDUCT.md
24
+ CONTRIBUTING.md
25
+ SECURITY.md
26
+
27
+ # Tests (not needed at runtime)
28
+ tests/
29
+ *.test.py
30
+
31
+ # Hermes plugin (installed separately)
32
+ hermes-plugin/
33
+
34
+ # CI/CD
35
+ .github/
36
+
37
+ # IDE
38
+ .vscode/
39
+ .idea/
40
+
41
+ # OS
42
+ .DS_Store
43
+ Thumbs.db
44
+
45
+ # Coverage
46
+ htmlcov/
47
+ .coverage
48
+ .coverage.*
49
+
50
+ # Environment
51
+ .env
52
+ .env.*
53
+
54
+ # Pre-commit
55
+ .pre-commit-config.yaml
56
+
57
+ # Config
58
+ Makefile
59
+ MANIFEST.in
60
+ pyproject.toml
61
+ docker-compose.yml
@@ -0,0 +1,39 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ ruff:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - name: Set up Python
16
+ uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.12"
19
+
20
+ - name: Install uv
21
+ uses: astral-sh/setup-uv@v3
22
+ with:
23
+ enable-cache: true
24
+
25
+ - name: Install dependencies
26
+ run: |
27
+ uv venv
28
+ source .venv/bin/activate
29
+ uv pip install ruff
30
+
31
+ - name: Check formatting
32
+ run: |
33
+ source .venv/bin/activate
34
+ ruff format src/ tests/ --check
35
+
36
+ - name: Lint
37
+ run: |
38
+ source .venv/bin/activate
39
+ ruff check src/ tests/
@@ -0,0 +1,21 @@
1
+ name: Pre-commit CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ pre-commit:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - name: Set up Python
16
+ uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.12"
19
+
20
+ - name: Run pre-commit
21
+ uses: pre-commit/action@v3.0.1
@@ -0,0 +1,63 @@
1
+ name: Release & Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ release-and-publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: write
13
+ id-token: write
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ with:
18
+ fetch-depth: 0
19
+
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.12"
24
+
25
+ - name: Install uv
26
+ uses: astral-sh/setup-uv@v3
27
+ with:
28
+ enable-cache: true
29
+
30
+ - name: Install build dependencies
31
+ run: uv venv && source .venv/bin/activate && uv pip install build
32
+
33
+ - name: Build package
34
+ run: |
35
+ source .venv/bin/activate
36
+ python -m build
37
+
38
+ - name: Generate changelog
39
+ id: changelog
40
+ run: |
41
+ TAG="${{ github.ref_name }}"
42
+ VERSION="${TAG#v}"
43
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
44
+ awk -v ver="$VERSION" '
45
+ $0 ~ "^## \\\\[" ver "\\\\]" { found=1; next }
46
+ found && /^## / { exit }
47
+ found { print }
48
+ ' CHANGELOG.md > _release_body.md || true
49
+
50
+ - name: Create GitHub Release
51
+ uses: softprops/action-gh-release@v2
52
+ with:
53
+ body_path: _release_body.md
54
+ generate_release_notes: false
55
+ make_latest: true
56
+ files: dist/*
57
+
58
+ - name: Publish to PyPI
59
+ uses: pypa/gh-action-pypi-publish@release/v1
60
+ with:
61
+ packages-dir: dist/
62
+ # Uncomment to test on TestPyPI first:
63
+ # repository-url: https://test.pypi.org/legacy/
@@ -0,0 +1,69 @@
1
+ name: Smoke Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ smoke:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v3
26
+ with:
27
+ enable-cache: true
28
+ cache-dependency-glob: "**/pyproject.toml"
29
+
30
+ - name: Build package
31
+ run: |
32
+ uv venv
33
+ source .venv/bin/activate
34
+ uv pip install build
35
+ python -m build
36
+
37
+ - name: Install from built wheel
38
+ run: |
39
+ source .venv/bin/activate
40
+ uv pip install dist/*.whl
41
+
42
+ - name: Smoke test — CLI help
43
+ run: |
44
+ source .venv/bin/activate
45
+ sysstable --help
46
+
47
+ - name: Smoke test — subcommand exists
48
+ run: |
49
+ source .venv/bin/activate
50
+ sysstable init --help
51
+ sysstable start --help
52
+ sysstable status --help
53
+ sysstable history --help
54
+ sysstable trend --help
55
+ sysstable kill-list --help
56
+ sysstable processes --help
57
+ sysstable never-kill --help
58
+ sysstable resolution-history --help
59
+ sysstable uninstall --help
60
+
61
+ - name: Smoke test — import check
62
+ run: |
63
+ source .venv/bin/activate
64
+ python3 -c "from sysstable import thresholds, config, collector, database, events, daemon, socketd, cli, process_watch, state_machine, resolver; print('All modules import OK')"
65
+
66
+ - name: Smoke test — plugin imports
67
+ run: |
68
+ source .venv/bin/activate
69
+ python3 -c "import sys; sys.path.insert(0, 'hermes-plugin'); from rapidwebs_sysstable import register; print('Plugin imports OK')"
@@ -0,0 +1,60 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
19
+
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+
23
+ - name: Set up Python ${{ matrix.python-version }}
24
+ uses: actions/setup-python@v5
25
+ with:
26
+ python-version: ${{ matrix.python-version }}
27
+
28
+ - name: Install uv
29
+ uses: astral-sh/setup-uv@v3
30
+ with:
31
+ enable-cache: true
32
+ cache-dependency-glob: "**/pyproject.toml"
33
+
34
+ - name: Install dependencies
35
+ run: |
36
+ uv venv
37
+ source .venv/bin/activate
38
+ uv pip install -e ".[dev]"
39
+
40
+ - name: Run tests with coverage
41
+ run: |
42
+ source .venv/bin/activate
43
+ uv pip install pytest-cov
44
+ pytest tests/ -v --tb=short --cov=src/sysstable --cov-report=xml --cov-report=term-missing
45
+
46
+ - name: Upload coverage to Codecov
47
+ if: matrix.python-version == '3.12'
48
+ uses: codecov/codecov-action@v4
49
+ with:
50
+ file: ./coverage.xml
51
+ fail_ci_if_error: false
52
+ token: ${{ secrets.CODECOV_TOKEN }}
53
+
54
+ - name: Upload coverage artifact
55
+ if: matrix.python-version == '3.12'
56
+ uses: actions/upload-artifact@v4
57
+ with:
58
+ name: coverage-${{ github.sha }}
59
+ path: coverage.xml
60
+ retention-days: 7
@@ -0,0 +1,31 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # IDE
13
+ .vscode/
14
+ .idea/
15
+
16
+ # OS
17
+ .DS_Store
18
+ Thumbs.db
19
+
20
+ # Coverage
21
+ .coverage
22
+ htmlcov/
23
+ .coverage.*
24
+
25
+ # Environment
26
+ .env
27
+ .env.*
28
+
29
+ # Build artifacts
30
+ *.so
31
+ *.dylib
@@ -0,0 +1,18 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.4.0
4
+ hooks:
5
+ - id: ruff
6
+ args: [--fix]
7
+ - id: ruff-format
8
+
9
+ - repo: https://github.com/pre-commit/pre-commit-hooks
10
+ rev: v4.6.0
11
+ hooks:
12
+ - id: trailing-whitespace
13
+ - id: end-of-file-fixer
14
+ - id: check-yaml
15
+ - id: check-toml
16
+ - id: check-added-large-files
17
+ - id: check-merge-conflict
18
+ - id: debug-statements
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,84 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.2.0] — 2026-07-03
9
+
10
+ ### Added
11
+
12
+ - **CRITICAL severity level**: Added `Severity.CRITICAL` enum with critical watermark threshold; `_overall_severity()` upgraded to treat CRITICAL as highest
13
+ - **Process Intelligence Engine**: `ProcessSnapshot`/`KillListEntry` dataclasses, `fetch_all_processes()` with 5s timeout safety, lightweight mode (top 20 by memory) for NORMAL state
14
+ - **NoKillManager**: 3-layer protected-process manager (hard-coded + user config + CLI/ENV). Triple (pid, name, cmdline) matching prevents PID-recycling attacks. `SYSTABLE_NEVER_KILL` env var support
15
+ - **ProcessScorer**: Weighted memory/cpu/io/history scoring algorithm with false-positive heuristic (cached process detection penalty)
16
+ - **KillListGenerator**: Filter protected → score → sort → periodic DB persist. Tracks generation count for persistence interval
17
+ - **DB Schema**: 3 new tables — `kill_list_generations` (trigger/entries/ram), `resolution_events` (action/pid/signal/success), `process_snapshots` (full per-process metrics with pid+name index). 7 new query/save/prune methods
18
+ - **Pressure State Machine**: Full lifecycle — NORMAL → CRITICAL_DETECTED → CONFIRMING → COUNTDOWN → RESOLVING → RECOVERED (or MANUAL_INTERVENTION after max retries)
19
+ - **Resolution Executor**: `MemoryPressureResolver` with re-entrance guard, SIGTERM→SIGKILL chain with configurable timeout, pause/unpause with reverse linear backoff schedule, systemd service stop support, insufficient-memory-freed detection
20
+ - **CLI Commands**: `kill-list` (view generation history), `processes` (one-shot or --watch), `never-kill` (display protected list), `resolution-history` (event log). `--never-kill` on `sysstable start`
21
+ - **Plugin v0.2.0**: CRITICAL severity blocks ALL delegation in `pre_tool_call`, resolution context injection in `pre_llm_call`, `resolution_active` field in state output
22
+ - **Integration Tests**: Full e2e lifecycle test (NORMAL→RESOLVING→RECOVERED) and manual intervention test (3 failed retries)
23
+
24
+ ### Changed
25
+
26
+ - **DEFAULT_CONFIG**: 6 new config blocks — `memory_pressure`, `resolution`, `process_scoring`, `never_kill`; `thresholds.ram_available_mb` now includes `critical: 128`
27
+ - **Daemon loop**: Process snapshot collection during pressure states (FULL) and NORMAL (LIGHTWEIGHT); state machine integration; CRITICAL severity in state output
28
+ - **80 tests** (up from 27), 0 lint
29
+
30
+ ### Security
31
+
32
+ - Triple (pid, name, cmdline) matching prevents PID-recycling attacks
33
+ - Fork bomb mitigation: max 3 resolution cycles, then MANUAL_INTERVENTION state
34
+ - Re-entrance guard prevents concurrent resolution execution
35
+ - HARD_CODED_NO_KILL immutable frozen set for system-critical processes
36
+
37
+ ## [0.1.0] — 2026-07-02
38
+
39
+ ### Added (open-source package)
40
+
41
+ - **README**: full docs with badges, architecture diagram, quick start, config reference
42
+ - **LICENSE**: MIT
43
+ - **CONTRIBUTING.md**: dev workflow, branch strategy, commit conventions
44
+ - **CODE_OF_CONDUCT.md**: Contributor Covenant v2.1
45
+ - **SECURITY.md**: supported versions, reporting process, security considerations
46
+ - **CHANGELOG.md**: keepachangelog format
47
+ - **GitHub Actions**: tests (4 Python versions), lint (ruff), publish (PyPI), release (GitHub Releases)
48
+ - **Makefile**: install, test, lint, format, check, clean, build, publish, docker, systemd targets
49
+ - **MANIFEST.in**: include templates, plugins, docs in sdist
50
+ - **.pre-commit-config.yaml**: ruff lint + format, trailing whitespace, yaml/toml checks
51
+ - **Dockerfile**: multi-stage build, slim runtime, non-root user
52
+ - **docker-compose.yml**: volume mounts for /proc, /sys, persistence
53
+ - **.gitignore**: comprehensive ignores for Python, IDE, OS, build artifacts
54
+ - **pyproject.toml**: full metadata, classifiers, URLs, ruff config, pytest config
55
+ - **Bugfix**: config shallow copy → deep copy (nested dict isolation)
56
+ - **Bugfix**: orphan `main.py` placeholder removed
57
+ - **Bugfix**: events dispatch parameter naming (`thresholds_config` → `config`)
58
+ - **Bugfix**: webhook payload reference cleanup
59
+
60
+ ### Added (original release)
61
+
62
+ - **Daemon** (`sysstabled`): background collection loop, signal handling,
63
+ configurable interval (default 15s), SQLite WAL-mode storage with
64
+ configurable retention (24h–14d).
65
+ - **Collector**: psutil-based metric gathering for RAM, ZRAM, SWAP, CPU,
66
+ load averages, iowait, disk partitions, disk IO rates, network interfaces,
67
+ battery, temperatures, and uptime.
68
+ - **Threshold Engine**: configurable yellow/orange/red watermarks with
69
+ reverse-aware comparison (lower=worse for RAM/disk, higher=worse for CPU/temp).
70
+ Evaluated each cycle; highest severity determines overall system state.
71
+ - **Event Dispatch**: shell hooks, webhooks (HTTP POST), and Python extension
72
+ scripts — fired per-violation each cycle.
73
+ - **Unix Socket IPC**: daemon listens on `AF_UNIX`; CLI queries metrics
74
+ without polling.
75
+ - **CLI** (`sysstable`): 7 commands — `init`, `start`, `stop`, `status`,
76
+ `history`, `trend`, `uninstall`.
77
+ - **Hermes Plugin**: 2 hooks — `pre_tool_call` (blocks delegation on RED,
78
+ warns on YELLOW/ORANGE) and `pre_llm_call` (injects `[SYSTEM STATUS]`
79
+ context with violation details).
80
+ - **Systemd Service Template**: `--user` unit with `Restart=on-failure`.
81
+ - **Test Suite**: 20 tests covering collector, database, thresholds, config,
82
+ events, and plugin logic.
83
+ - **Packaging**: hatchling-based `pyproject.toml`, `sysstable` CLI entry point,
84
+ optional dev dependencies.
@@ -0,0 +1,53 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment:
18
+
19
+ - Demonstrating empathy and kindness toward other people
20
+ - Being respectful of differing opinions, viewpoints, and experiences
21
+ - Giving and gracefully accepting constructive feedback
22
+ - Accepting responsibility and apologizing to those affected by our mistakes
23
+ - Focusing on what is best for the overall community
24
+
25
+ Examples of unacceptable behavior:
26
+
27
+ - The use of sexualized language or imagery, and sexual attention or advances
28
+ - Trolling, insulting or derogatory comments, and personal or political attacks
29
+ - Public or private harassment
30
+ - Publishing others' private information without explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate
32
+
33
+ ## Enforcement Responsibilities
34
+
35
+ Project maintainers are responsible for clarifying and enforcing our standards
36
+ of acceptable behavior and will take appropriate and fair corrective action.
37
+
38
+ ## Scope
39
+
40
+ This Code of Conduct applies within all community spaces, and also applies when
41
+ an individual is officially representing the community in public spaces.
42
+
43
+ ## Enforcement
44
+
45
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
46
+ reported to the project team at dev@rapidwebs.com. All complaints will be
47
+ reviewed and investigated promptly and fairly.
48
+
49
+ ## Attribution
50
+
51
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
52
+ version 2.1, available at
53
+ https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
@@ -0,0 +1,85 @@
1
+ # Contributing to RapidWebs-SysStable
2
+
3
+ Thank you for considering contributing! This document outlines the process.
4
+
5
+ ## Code of Conduct
6
+
7
+ This project adheres to a [Code of Conduct](CODE_OF_CONDUCT.md). By participating
8
+ you agree to uphold its terms.
9
+
10
+ ## Getting Started
11
+
12
+ 1. **Fork** the repository.
13
+ 2. **Clone** your fork:
14
+ ```bash
15
+ git clone https://github.com/your-username/rapidwebs-sysstable.git
16
+ cd rapidwebs-sysstable
17
+ ```
18
+ 3. **Create a virtual environment**:
19
+ ```bash
20
+ uv venv
21
+ source .venv/bin/activate
22
+ ```
23
+ 4. **Install dev dependencies**:
24
+ ```bash
25
+ uv pip install -e ".[dev]"
26
+ ```
27
+
28
+ ## Development Workflow
29
+
30
+ 1. **Create a branch** off `main`:
31
+ ```bash
32
+ git checkout -b feat/your-feature-name
33
+ ```
34
+
35
+ 2. **Run tests** before and after your changes:
36
+ ```bash
37
+ pytest tests/ -v
38
+ ```
39
+
40
+ 3. **Lint your code**:
41
+ ```bash
42
+ ruff check src/ tests/
43
+ ruff format src/ tests/ --check
44
+ ```
45
+
46
+ 4. **Run the full verification**:
47
+ ```bash
48
+ make check
49
+ ```
50
+
51
+ 5. **Commit** using conventional commits:
52
+ - `feat: ...` — new feature
53
+ - `fix: ...` — bug fix
54
+ - `docs: ...` — documentation
55
+ - `refactor: ...` — code restructure
56
+ - `test: ...` — tests only
57
+ - `ci: ...` — CI/CD changes
58
+
59
+ 6. **Push and open a Pull Request** against `main`.
60
+
61
+ ## Project Structure
62
+
63
+ ```
64
+ src/sysstable/ # Main package
65
+ ├── __init__.py # Version + public API
66
+ ├── __main__.py # python -m sysstable
67
+ ├── daemon.py # Collection loop + state management
68
+ ├── collector.py # psutil metric wrappers
69
+ ├── thresholds.py # Watermark matching engine
70
+ ├── events.py # Shell hooks, webhooks, python extensions
71
+ ├── database.py # SQLite store (WAL mode)
72
+ ├── socketd.py # Unix socket IPC
73
+ ├── cli.py # Click CLI
74
+ └── config.py # YAML config loader
75
+ tests/ # Pytest test suite
76
+ docs/ # Systemd service, docs
77
+ hermes-plugin/ # Hermes integration plugin
78
+ ```
79
+
80
+ ## Testing Guidelines
81
+
82
+ - Write tests before fixing bugs (TDD preferred).
83
+ - Use `tempfile` for ephemeral SQLite databases.
84
+ - Tests must not require a running daemon.
85
+ - Test threshold logic with edge cases (None values, boundary conditions).
@@ -0,0 +1,32 @@
1
+ # syntax=docker/dockerfile:1
2
+ FROM python:3.12-slim AS base
3
+
4
+ RUN apt-get update && apt-get install -y --no-install-recommends \
5
+ gcc \
6
+ && rm -rf /var/lib/apt/lists/*
7
+
8
+ # ── builder ──
9
+ FROM base AS builder
10
+ WORKDIR /build
11
+ COPY . .
12
+ RUN pip install build && python -m build
13
+
14
+ # ── runtime ──
15
+ FROM python:3.12-slim
16
+
17
+ RUN adduser --system --group sysstable
18
+
19
+ RUN apt-get update && apt-get install -y --no-install-recommends \
20
+ procps \
21
+ curl \
22
+ && rm -rf /var/lib/apt/lists/*
23
+
24
+ COPY --from=builder /build/dist/*.whl /tmp/
25
+ RUN pip install /tmp/rw_sysstable-*.whl && rm /tmp/rw_sysstable-*.whl
26
+
27
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
28
+ CMD sysstable status >/dev/null 2>&1 || exit 1
29
+
30
+ USER sysstable
31
+ ENTRYPOINT ["sysstable"]
32
+ CMD ["start", "--foreground"]
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 RapidWebs Enterprise
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ include *.toml
2
+ recursive-include src/sysstable *.py
3
+ recursive-include hermes-plugin *
4
+ recursive-include docs *
5
+ recursive-include tests *.py