mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 13:29:19 +08:00
feat/https-compose-caddy
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b235bc2d27 |
fix(ci): verify installer provenance in build workflows (#4677)
## Current maintainer status (2026-11-10, current-main refresh) Published head: `db4bdd71e7ddc1a72316445ef0d16a7d90b62951`, containing upstream main `a385ea8e60a14c1511d82b21d518421af35deab2` through a clean mechanical merge. All 13 remediation files are byte-identical to reviewed head `81ff3ed384afbd404c48fd79d6bed41e8d647a99`; no installer, action metadata, or checksum selection changed. Fresh focused Windows checks: 61 passed and 23 platform skips. Fresh WSL offline bootstrap/hook fixtures: 23 passed, with one pytest configuration warning. These local checks use fixtures and do not claim live vendor, provider, or native GUI execution. Exact-head CI, including Docker-native, and the Init, Wrap, Rust, governance, changelog, and merge-conflict workflows succeeded. Security remains FAILURE: the OpenCode npm audit reports two moderate findings through Effect advisory GHSA-chp3-j5qr-2vfr. The security workflow and affected OpenCode package manifest/lock are byte-identical to current main, establishing an inherited dependency finding. This is not an all-green result or a fresh audit of main. No workflow rerun, dependency downgrade, or advisory override was performed on this branch. Independent human review and integration remain required. No self-approval or merge was performed. Other branch publication and execution holds remain active. All older qualification below belongs to its recorded historical heads. --- ## Description Build validation jobs fetched mutable installer scripts, and the pinned commitlint action still declared a mutable Docker image tag. This pins that image digest, verifies workflow-tool archives and cached binaries, and replaces the Docker bootstrap scripts with pinned, verified sources. ## Type of Change - [x] Bug fix ## Changes Made - Preserve Rust 1.95.0, minimal/rustfmt/clippy options, Node 24, npm 12.2.1, and OpenCode 1.17.8. - Preserve Debian userland architecture detection, Rustup ARM fallback, and OpenCode x64 AVX2/baseline selection. - Use an official Node image pinned by manifest digest; retain npm/corepack trees and explicit runtime libraries. - Add offline bootstrap tests for failed downloads, corrupt bytes, unsupported targets, symlinks, and option forwarding. ## Testing - [x] Offline bootstrap tests pass (stdlib unittest, 16 cases). - [x] Ruff lint/format pass for the two new test files; shell syntax and whitespace checks pass. - [x] Exact-head hosted CI passed, including platform tests and Docker-native, Init, and Wrap build/container checks. ### Test Output ```text python3 -m unittest discover -s tests/test_install -p 'test_*bootstrap.py' ................ Ran 16 tests in 0.770s OK ``` ## Real Behavior Proof - Environment: Ubuntu 24.04 under WSL, exact candidate |
||
|
|
2973ca593d |
ci: pin every GitHub Action to a commit SHA (#4671)
## Description Every third-party action in `.github/` ran from a version tag like `actions/checkout@v7`. A tag can be moved to other code at any time. That is how `tj-actions/changed-files` leaked CI secrets from ~23,000 repos in March 2025. Here a moved tag would run with the release job's PyPI OIDC token (`id-token: write`) and the Docker job's `packages: write` token. Pinning to a commit SHA closes that, and a new test keeps it closed. Closes # ## Type of Change - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Performance improvement - [x] Code refactoring (no functional changes) ## Changes Made - All 195 third-party `uses:` refs in 25 files now name the commit their tag points to today, with the version as a comment: `actions/checkout@3d3c42e5... # v7.0.1`. No action version changes. - Dependabot's existing `github-actions` config updates SHA pins and their version comments, so the pins stay current. - Pin dtolnay/rust-toolchain stable and 1.95.0 branches to their existing commit heads. The stable action retains its runtime toolchain input/default; the 1.95.0 action embeds toolchain: 1.95.0. This preserves each call site's existing toolchain selection. - New `test_every_action_is_pinned_to_a_commit_sha` in `scripts/tests/test_ci_workflow.py` fails on any tag-pinned action and lists each one. - Three tests in `tests/test_release_workflows.py` matched the old tag text (`setup-buildx-action@v4`, `gh-action-pypi-publish@vX.Y.Z`, `release-please-action@v4/v5`). They now match the SHA pin and its version comment. ## Testing - [x] Unit tests pass (`pytest`) - [x] Linting passes (`ruff check .`) - [ ] Type checking passes (`mypy headroom`) - [x] New tests added for new functionality - [x] Manual testing performed ### Test Output ```text $ uv run --frozen --extra dev pytest -q scripts/tests/test_ci_workflow.py scripts/tests/test_pr_health_workflow.py scripts/tests/test_normalize_release_pr_bodies.py tests/test_release_workflows.py 87 passed in 0.87s $ uv run --frozen --extra dev pytest -q scripts/tests/test_pr_health_labels.py scripts/tests/test_version_sync.py tests/test_cli/test_wrap_copilot.py tests/test_learn/test_subagent_scanning.py tests/test_plugin_manifests.py tests/test_pr208_changes.py 114 passed in 1.32s $ uvx ruff check scripts/tests/test_ci_workflow.py tests/test_release_workflows.py && uvx ruff format --check <same> All checks passed! ``` ## Real Behavior Proof - Environment: macOS, Python 3.12 via `uv run --frozen --extra dev`, branch cut from `main` at |
||
|
|
7f44a64490 |
ci(release): announce completed GitHub Releases in Slack (#3607)
## Description - announce a GitHub Release in Slack only after `create-release` has successfully uploaded its assets - build an accessible Block Kit payload with the exact release name, tag, repository, actor, and GitHub Release link - isolate the incoming webhook to the delivery step and fail closed on missing configuration or an unexpected Slack response - add a reproducible `act` smoke workflow whose `ACT=true` guard builds and validates the production payload without sending network traffic ## Changes Made - Adds a gated release-notification job, a local composite action, a payload builder, and smoke/regression coverage. ## Boundary and rollout This notification means **the GitHub Release and its assets are ready**. It intentionally does not claim that every package registry publish succeeded, matching the existing `create-release` contract. Configure `SLACK_RELEASES_WEBHOOK_URL` as a repository Actions secret containing an incoming webhook already bound to `#headroom`. Slack incoming webhooks cannot override their configured channel. No Slack request was made while developing or validating this PR. This is additive to the current publication flow and does not implement or bypass the future Gate B work tracked by Linear HEAOSS-19. ## Testing - Rebased onto current `main` at `94206e265`; refreshed focused qualification on `477f68047`. - [x] Focused tests pass ### Test Output ```text 68 passed ``` - `uv run --extra dev pytest tests/test_release_workflows.py tests/test_release_version.py -q` (68 passed) - `uv run --extra dev ruff check .github/actions/release-slack-notification/build_payload.py tests/test_release_workflows.py` - `uv run --extra dev ruff format --check .github/actions/release-slack-notification/build_payload.py tests/test_release_workflows.py` - `actionlint .github/act/release-slack-notification.yml .github/workflows/release.yml` - `act workflow_dispatch -W .github/act/release-slack-notification.yml -j smoke --pull=false` ## Type of Change - [x] CI / release automation ## Real Behavior Proof - Environment: maintainer macOS/Python 3.13 checkout at aedf2c2e. - Exact command / steps: `python -m pytest tests/test_release_workflows.py tests/test_release_version.py -q`. - Observed result: 68 passed; current hosted build, test and security checks pass. Payload and workflow guards are covered by the focused tests. - Not tested: delivery to the production Slack webhook. No notification or release was sent during this review. ## Runtime Rollout Safety - Rollout-managed feature(s): no runtime feature; release notification only. - Minimum rollout channel: human-reviewed repository workflow deployment. - Stable/default behavior changed: successful GitHub Release asset publication triggers the notification. - Kill switch / disable path: disable or revert the notification job; missing webhook configuration fails that job. - Unsafe override required: no. - Qualification impact: notification signifies GitHub Release assets ready, not registry-wide publication success. - Rollback path: revert the additive notification workflow/action. ## Review Readiness - [x] I have performed a self-review - [x] This PR is ready for human review |
||
|
|
d633e8172c |
fix(windows): pin UTF-8 encoding on text-mode subprocess calls (#1311)
Fixes #1310. ## Description On Windows, `headroom` startup crashes a subprocess reader thread: ``` UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 7894: character maps to <undefined> ... subprocess.py _readerthread -> buffer.append(fh.read()) ... encodings/cp1252.py ``` Text-mode `subprocess` calls omit `encoding=`, so Python decodes child output with the locale codec (**cp1252** on Windows). Children that emit UTF-8 ??? `cbm index_repository` (indexing sources with chars like `???`/`???`), `claude mcp get/add`, the memory-sync process ??? produce bytes invalid in cp1252 and kill the reader thread. Linux/macOS default to UTF-8, so it's invisible there. ## Type of Change - [x] Bug fix (non-breaking change that fixes an issue) ## Changes Made - Add `encoding="utf-8", errors="replace"` to every text-mode (`text=True` / `universal_newlines=True`) subprocess call in the `headroom/` package (~50 call sites; several already had it). - `errors="replace"` (not `ignore`) so corrupt bytes surface as `???` rather than vanishing from parsed output. - Add `tests/test_cli/test_subprocess_utf8_encoding.py`: an AST guard asserting every text-mode subprocess call pins `encoding=`. The runtime crash can't reproduce on UTF-8 CI, so the invariant is enforced at the source level instead. ## Testing - [x] Unit tests pass (`pytest`) - New guard test passes (validates 51 call sites). - `tests/test_install`, `tests/test_cli/test_mcp.py`, `tests/test_mcp_registry` pass. (`test_runtime_start_lock_blocks_another_process` fails on this Windows box, but it fails identically on unmodified `main` ??? a pre-existing `msvcrt` lock flake, unrelated.) ### Test Output ```text > python -m pytest tests/test_cli/test_subprocess_utf8_encoding.py -q 1 passed in 0.12s > python -m pytest tests/test_install/ tests/test_cli/test_mcp.py tests/test_mcp_registry/ -q 133 passed, 2 skipped in 15.34s ``` ## Real Behavior Proof - Environment: Windows 11, Python 3.13.13. - Exact command / steps: Started `headroom` without `PYTHONUTF8=1` on a repo with UTF-8 chars in indexable files. Observed the `UnicodeDecodeError` crash. Applied the fix (pinning `encoding="utf-8"` on all text-mode subprocess calls). Re-ran. No crash. The AST guard enforces the invariant on CI (which runs UTF-8 locales and cannot reproduce the cp1252 crash natively). - Observed result: Subprocess reader threads no longer crash on UTF-8 output under cp1252 locale. - Not tested: All third-party tools that `headroom` shells out to; each was given `errors="replace"` as a safety net. ## Workaround for affected users (before fix is deployed) `PYTHONUTF8=1` (PowerShell: `$env:PYTHONUTF8=1; headroom ...`). ## Review Readiness - [x] I have performed a self-review - [x] This PR is ready for human review --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
ad7993bf15 |
fix(codex): stop pinning Codex memory MCP to one project db (#1269)
## Description Stop `headroom wrap codex --memory` from pinning the global `headroom_memory` MCP server to one absolute SQLite path. Today the wrapper writes `--db <wrap-cwd>/.headroom/memory.db` into `~/.codex/config.toml`, which makes later Codex sessions either reopen a stale project-local DB or fail with `unable to open database file` when that original path disappears. This change lets the MCP server use its existing per-cwd default again, so each Codex session resolves `.headroom/memory.db` from the active project instead of a serialized past cwd. Closes #1147 The current Codex-memory config surface was shaped by https://github.com/chopratejas/headroom/issues/462 and https://github.com/chopratejas/headroom/issues/730; this PR keeps that surface project-scoped again instead of globally pinning one DB. ## Type of Change - [x] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Performance improvement - [ ] Code refactoring (no functional changes) ## Changes Made - remove the injected `--db` argument from the global `headroom_memory` Codex MCP block while keeping `--user` intact - preserve the wrap-time local `.headroom/memory.db` setup and Claude-memory import path for the current project - treat only wrap-owned Codex markers as snapshot-suppression and unwrap-cleanup signals, so pre-existing named MCP blocks still back up and restore - log a startup diagnostic from `headroom.memory.mcp_server` that records the configured DB path, config source, cwd/project root, resolved storage scope, path existence/readability, and whether the path was static or cwd-derived - add a shared MCP SDK test stub so both the memory MCP and CCR MCP test surfaces still run in CI when `mcp` is absent - make the shared MCP stub re-import target modules under the stubbed dependency set and restore any pre-existing target module object plus dotted parent-package attribute state after cleanup - add focused regressions and guard coverage for the persisted Codex config shape, named-MCP marker backup and restore, the no-backup memory-only unwrap path, the wrap-memory-then-unwrap cleanup path, the failed-wrap memory-only cleanup path, the startup-diagnostic path classification, the shared-store CCR retrieval path, and the shared MCP stub import lifecycle - add a `CHANGELOG.md` entry for the user-visible Codex memory scoping fix ## Testing - [x] Unit tests pass (`pytest`) - [x] Linting passes (`ruff check .`) - [ ] Type checking passes (`uv run mypy headroom`) - [x] New tests added for new functionality - [ ] Manual testing performed ### Test Output ```text uv run pytest tests/test_ccr_mcp_server.py tests/test_memory/test_mcp_server.py tests/test_cli/test_wrap_codex.py tests/test_mcp_stub.py ======================== 78 passed, 1 warning in 5.96s ======================== Pytest warning: PytestConfigWarning: Unknown config option: asyncio_mode Pytest post-success atexit noise: PermissionError: [WinError 5] Access is denied: 'C:\Users\Rod\AppData\Local\Temp\pytest-of-Rod\pytest-current' uv run ruff check headroom/cli/wrap.py headroom/memory/mcp_server.py tests/_mcp_stub.py tests/test_ccr_mcp_server.py tests/test_cli/test_wrap_codex.py tests/test_mcp_stub.py tests/test_memory/test_mcp_server.py All checks passed! uv run ruff format headroom/cli/wrap.py headroom/memory/mcp_server.py tests/_mcp_stub.py tests/test_ccr_mcp_server.py tests/test_cli/test_wrap_codex.py tests/test_mcp_stub.py tests/test_memory/test_mcp_server.py --check 7 files already formatted ``` ## Real Behavior Proof - Environment: isolated temp project directories, a temp Codex home, the real `wrap codex` and `unwrap codex` CLI commands under pytest, a mocked missing-`codex` launch path for the failed-wrap cleanup case, and shared MCP-SDK stubs for the memory MCP and CCR MCP test modules so CI still exercises those paths without a real `mcp` install. - Exact command / steps: run `uv run pytest tests/test_ccr_mcp_server.py tests/test_memory/test_mcp_server.py tests/test_cli/test_wrap_codex.py tests/test_mcp_stub.py`; prove the persisted config shape with `TestCodexMemoryMcpConfig::test_inject_omits_db_and_replaces_existing_memory_block`; prove prepare-only wrap cleanup with `test_wrap_codex_memory_prepare_only_unwrap_removes_memory_mcp_without_prior_config`; prove failed-wrap cleanup with `test_wrap_codex_memory_launch_failure_unwrap_cleans_memory_only_config`; guard pre-existing named Codex MCP preservation with `test_memory_only_wrap_restores_preexisting_named_mcp_block` and `test_memory_only_wrap_without_backup_preserves_named_mcp_block`; prove the startup diagnostic classifications with `test_memory_mcp_startup_context_reports_dynamic_project_db` and `test_memory_mcp_startup_context_reports_static_external_db`; prove the shared-store CCR retrieval path with `test_mcp_uses_shared_singleton_store` and `test_mcp_retrieves_proxy_stored_content`; prove stub import cleanup with `test_import_module_with_mcp_stub_imports_target_and_cleans_up`, `test_import_module_with_mcp_stub_reimports_target_and_restores_originals`, and `test_import_module_with_mcp_stub_cleans_up_dotted_target_attribute`. - Observed result: the persisted global `headroom_memory` block now keeps `--user` but omits `--db`; prepare-only memory setup still bootstraps the current project's `.headroom/memory.db`; `headroom unwrap codex --no-stop-proxy` now removes both the prepare-only generated config and the failed-wrap memory-only config instead of leaving `[mcp_servers.headroom_memory]` behind; pre-existing named Codex MCP blocks remain restorable across both normal and no-backup memory-only unwrap paths because only wrap-owned markers suppress backups or trigger named-block cleanup; the memory MCP server now logs whether its DB path came from the cwd default or an explicit static path, along with the resolved path and scope it will open; CI can exercise both MCP test modules even when the `mcp` package is absent from the shard environment, and the shared stub now re-imports target modules under the stubbed SDK while restoring both dependency and dotted parent-package target-module import state after cleanup. - Not tested: full end-to-end interactive Codex CLI launch. ## Review Readiness - [x] I have performed a self-review - [x] This PR is ready for human review ## Checklist - [x] My code follows the project's style guidelines - [x] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] I have updated the CHANGELOG.md if applicable ## Additional Notes The code change stays narrowly scoped to Codex memory config persistence, cleanup, and startup observability. It does not widen into larger memory-routing redesign or startup-failure recovery logic. |
||
|
|
2a91cbb4b4 |
refactor: single-wheel maturin build backend (fixes #355)
Eliminates the dual-package architecture that was the root cause of #355. `pip install headroom-ai` now produces ONE wheel containing both the Python source (headroom/*.py) and the compiled Rust extension (headroom/_core.so). No more separate `headroom-core-py` package, no more chicken-and-egg with PyPI publication, no more wheelhouse / PIP_FIND_LINKS / composite-action plumbing in CI. This is the canonical pattern used by cryptography, polars, ruff, pydantic-core, and other Rust-as-core Python packages. Honors the "Rust as core engine" direction. ## What changed - pyproject.toml: `[build-system]` swapped from hatchling to maturin. `[tool.hatch.*]` deleted; `[tool.maturin]` added pointing at `crates/headroom-py/Cargo.toml` for the cdylib. `python-source = "."` picks up the root `headroom/` package directly (dashboard HTML templates and other non-Python files included automatically). - crates/headroom-py/pyproject.toml: deleted. The crate is no longer a separate published package; its Cargo.toml stays as the cdylib build target invoked via `[tool.maturin] manifest-path`. - crates/headroom-py/python/: deleted (placeholder layout for the old separate package). ## CI updates - ci.yml: `test` / `test-extras` / `test-agno` jobs simplified — Rust toolchain set up before `pip install -e .` (which now invokes maturin via build-system). Removed the "build wheel + symlink .so" dance. `build` job swapped from `python -m build` (hatch) to `maturin build` + `maturin sdist`. - release.yml: collapsed dual-package matrix into one. New `build-wheels` matrix produces cross-platform wheels for cp310/11/12/13 × {linux x86_64, linux aarch64, macos x86_64, macos aarch64}. New `collect-dist` aggregator merges artifacts. publish-pypi consumes the merged dist. - init-native-e2e.yml: dropped windows-latest from the matrix — upstream `esaxx-rs` (/MT) and `ort-sys` (/MD) link with conflicting MSVC C runtime libraries, so the Rust extension cannot build for win_amd64 today. Tracked as a follow-up; not a blocker for Linux+macOS. - headroom-e2e-setup: composite action now sets up Rust toolchain + Swatinem/rust-cache before `pip install -e .[proxy]`. - eval.yml, publish.yml, rust.yml: same pattern — rust toolchain before install. rust.yml's wheels job builds from root pyproject.toml (no more `-m crates/headroom-py/Cargo.toml`). - e2e/init/Dockerfile, e2e/wrap/Dockerfile: install rust + maturin in the build stage; copy `crates/` + workspace `Cargo.toml/lock` so the install can build the extension. Dropped `HEADROOM_REQUIRE_RUST_CORE=false` from wrap-e2e — the image now ships the full Rust core. - Dockerfile (main): simplified — no more Layer 2/3 dance with `headroom-core-py` install + symlink. Single `uv pip install` builds + installs everything. - .devcontainer/Dockerfile: rust toolchain + libssl-dev + maturin added so `uv sync` builds the extension inside the devcontainer. ## Lockfile + script - uv.lock: regenerated. No `headroom-core-py` entries remain. - scripts/build_rust_extension.sh: simplified from a symlink-into-tree workaround to a thin wrapper around `pip install -e .`. The maturin build-backend handles placement automatically. ## Local validation (all green on macOS aarch64) 1. Clean venv `pip install -e .` → `from headroom._core import …` works. 2. `maturin build --release` → 13.8 MB wheel, 336 files including `headroom/_core.cpython-311-darwin.so` (32 MB cdylib) and `headroom/dashboard/templates/dashboard.html`. 3. `pip install <wheel>` in fresh venv → import works. 4. Wheel contents verified via `unzip -l`. 5. `pytest tests/test_transforms/test_diff_compressor.py` — 29 passed. 6. `pytest tests/test_relevance.py` — 30 passed. 7. `cargo build --workspace` + `cargo test --workspace` — all green. 8. `make ci-precheck` — 176 Python tests + Rust + commitlint green. ## Migration notes Users on `pip install headroom-ai` get the Rust core automatically (linux + macos wheels). sdist installs require rust toolchain available locally — pip will build via maturin. Closes #355 Supersedes #357 (workarounds-based fix abandoned in favor of architectural fix) |
||
|
|
bc7a95a7c7 |
ci(init-native): install [proxy] extras and use pwsh for Windows shim check
Two fixes for the init-native-e2e matrix surfaced on PR #256: 1. Composite action installed `headroom` without extras, but `headroom/cli/__init__.py` eagerly imports `proxy.server` (via `cli/proxy.py`), which requires `fastapi`. All 6 POSIX jobs hit `ModuleNotFoundError: No module named 'fastapi'` before `init` ran. Fix: install `-e .[proxy]` to match the Docker e2e image. 2. On Windows, shims are `.cmd` files and Git Bash's `which` cannot resolve them (exact-match only). Python's `shutil.which` (used by `headroom init`) honors PATHEXT and finds the shim fine, but the pre-flight `which` step failed first. Fix: use `Get-Command` via `pwsh` for the Windows verification step. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
0cfbc3f436 |
ci: add init-native-e2e workflow across linux / macos / windows
Existing Docker init-e2e runs on ubuntu only. Platform-specific bugs
(Windows path separators in written hook commands, PowerShell-vs-bash
matcher strings, macOS keychain prompts, shutil.which PATHEXT quirks)
slip past it. Add a matrix workflow that drops a noop shim for each
target agent and runs ``headroom init -g <target>`` on each of the
three supported OSes, then asserts the settings file was written to
the platform-correct location.
Matrix: [ubuntu-latest, macos-latest, windows-latest] x [claude,
codex, copilot]. ``openclaw`` is excluded because it delegates to
``headroom wrap openclaw`` which needs a real OpenClaw CLI and can't
be stubbed with a noop shim; the Docker suite already covers its
negative path.
Common setup (Python install, editable headroom install, shim drop,
PATH wiring) is factored into a composite action at
.github/actions/headroom-e2e-setup so follow-up per-command workflows
(install-native-e2e, wrap-native-e2e) can be near-copies that only
supply their matrix and assertion blocks. The composite action uses
the cross-platform shim scripts from e2e/_lib/make_shim.{sh,ps1} that
landed with the harness refactor.
Scoped trigger: pull_request touching init code OR the harness, plus
pushes to main and manual dispatch. This avoids burning CI minutes on
every push to unrelated feature branches while still gating every PR
that could regress init behavior.
Not verified locally: Windows runner behavior. Reviewer should watch
the first matrix run on PR.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|