mirror of
https://github.com/beenuar/AiSOC.git
synced 2026-11-25 09:35:49 +08:00
f4cea19023c331c052d1585e45ec76cc4f7fcab7
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e78f31768c |
Move all fourteen ruff declarations to 0.16, and stop the lint gate at services/ (#861)
* Reformat the tree under ruff 0.16, excluding the subtree nobody may edit Mechanical. `ruff format` with no other change, so the diff can be read as "the formatter moved" rather than reviewed line by line: 218 files, 862 insertions against 1075 deletions, almost all of it collapsing calls that 0.4.10 wrapped and 0.16 fits inside the 140-column limit. `plans/` is excluded in `ruff.toml` rather than reformatted. It is the archived prototype subtree that `.github/workflows/codeql.yml` already excludes and `scripts/check_mypy_baseline.py` excludes from every coverage direction, and the project rules forbid editing anything under it -- so formatting it would be a diff nobody may take. 844 lint findings and ~280 unformatted files live there. They are excluded because they cannot be fixed, which is a different statement from saying the code is clean. * Move all fourteen ruff declarations to 0.16, and stop the lint gate at services/ The bump alone reds every open pull request: `ruff format --check` is a hard gate on the required `Python - Lint & Type-check` job and 0.16 formats differently from 0.4.10. The reformat is the previous commit; this one moves the pin, fixes the findings, and answers the scope question. Fourteen declarations now read `>=0.16.8,<0.17` -- seven manifests, three workflows, `.devcontainer/Dockerfile`, and the three `poetry.lock` files that resolve it (now 0.16.9, which is byte-identical to 0.16.8 on both format and lint across this tree). The three findings 0.16 reports on `services/` are fixed, not suppressed: two `C420` comprehensions become `dict.fromkeys` (both values are string literals, so the shared-value hazard does not apply) and one `UP031` percent-format becomes an f-string in a test that counts characters. All three rewrites were asserted equal to the originals before being kept. Scope. `ruff check services/` left `scripts/` -- every CI gate in this repository, the code the rest of its claims are verified by -- linted by nothing. Lint now covers `services/ scripts/ tests/ tools/`, the trees the root `ruff.toml` governs that nothing else lints, and `ruff format --check .` covers everything, because formatting has no semantic content and `.` needs no edit when a tree is added. That surfaced 17 findings outside `services/`, each fixed at the source: two `B007` loops switched to `.values()`, a `B904` re-raise in `security_audit.py` now chains `from exc`, two `E402` imports that genuinely follow a `sys.path` mutation carry a reason next to the marker, and two over-length lines were wrapped. `E501` is ignored for the two detection-spec data modules. Both open their rule table with `# fmt: off`, so the formatter is already opted out of that layout deliberately, and all 199 long lines are single dict or string literals -- 72 positive fixtures, 66 negative, 50 `match_when` clauses, 11 descriptions. Two named files, not `scripts/`. `packages/` and `plugins/` stay outside the lint gate, and the gap is a number rather than a shrug: 91 findings and 2. Two of the five packages are linted by their own workflows under their own configs, and bringing the three published SDKs under this gate means behaviour-touching fixes that belong in a change reviewed as such. * Make packages/aisoc-detections clean under the ruff its own workflow now installs `python-detections.yml` lints `aisoc_detections detections tests` under the pin this PR moved, so the package has to be clean under 0.16 too. Two findings, both fixed at the source rather than silenced: `Callable` moves to `collections.abc`, and a `# noqa: BLE001` that 0.16 correctly reports as unused becomes the sentence it was standing in for -- a detection module is third-party content, so any exception at import is the author's and becomes a DetectionError naming the file. --------- Co-authored-by: Beenu Arora <beenu@MacBook-Pro-3.local> |
||
|
|
f3348223a8 |
Five gates said OK over nothing; the probe that found them is now a gate (#823)
* Five gates said OK over nothing; the probe that found them is now a gate Copying scripts/ into an empty git repository and running every wired check found five reporting OK over a tree containing nothing: the detection validator behind the rule count on the front page certifying zero rules as valid, a dashboard check that failed on an empty directory and passed on a missing one, "OK: 0 published Go module path(s)", every self-link healthy over zero files, and a health-probe audit printing a table header and exiting 0. Those five were fixed. The probe was a one-off, so the next gate written could reintroduce the defect freely. scripts/check_gate_contract.py is that probe made permanent. It runs all 69 inventoried checks the way a workflow runs each one, inside a git repository holding only scripts/, and requires each to exit non-zero. The inventory comes from check_gate_coverage.py rather than a second scanner here, because two scanners drift the first time either learns something the other has not. A run that failed for a reason the empty tree did not cause is INCONCLUSIVE and fails rather than counting as a refusal. Every way CI runs a script is probed and the worst result decides, because four subcommands under one name are four gates. Two properties come with it, both enforced with empty exception lists: a root resolved through git rather than from __file__, and a declared --self-test. Sixty of sixty-nine did the former; fifty-four lacked the latter. scripts/gate_toolkit.py holds the single implementation of both. Found while building it: - check_gate_coverage.py decided "inspects the repository" partly by looking for Path(__file__) -- the idiom being migrated away from -- so moving six gates onto the shared resolver dropped them out of the inventory. - The first spelling of the root property matched repo_root anywhere in the text, and check_gate_coverage.py emits it as a JSON key, so a gate rooted at __file__ read as compliant on a key in its own output. - check_route_tenant_scope.py printed "scanned 0 routes across 0 files" and then "OK: every route taking a tenant identifier authenticates" against a services/ tree with no routes in it. - security_audit.py's pnpm, python and go arms each printed "0 findings" over a tree with no manifests, and get_repo_root() fell back to cwd. * Make every gate find gate_toolkit however it is loaded Five CI jobs failed with ModuleNotFoundError: No module named 'gate_toolkit'. Sixteen test modules load a gate with importlib.util.spec_from_file_location, which executes the file without putting its directory on sys.path — so the scripts were importable as programs and not as modules, and the scripts that already import a sibling carry the same tweak for the same reason. Each gate now inserts its own directory before the import. Also corrects the claim-to-gate tally in the compliance evidence pack, which quotes it in prose and was the second place the figure lives. --------- Co-authored-by: Beenu Arora <beenu@MacBook-Pro-3.local> |
||
|
|
f16978438b |
An invariant nothing enforced: zero CodeQL alerts, now actually gated (#815)
* An invariant nothing enforced: zero CodeQL alerts, now actually gated `apps/docs/docs/operations/security.md` has said since 2026-05-15 that the CodeQL alert count on `main` is zero and that this is enforced as a CI gate. Nothing enforced it. `codeql.yml` uploads SARIF and `codeql-action/analyze` does not fail a build on findings; `main` has no branch protection, so "Code scanning results" was not a required check either; `security.yml`'s only hard job is the claim-to-gate matrix; and nothing in the tree queried the code-scanning API. The scan itself was healthy and current, so stale-green and mixed-action-pin were both ruled out — the enforcement was simply imaginary, which is how two `note` alerts came to sit open under a documented zero. - Add `scripts/check_codeql_alerts.py` and wire it into the new `.github/workflows/codeql-alert-gate.yml` on push to `main`, on pull requests, after CodeQL completes, and daily. It fails on any open CodeQL alert at any severity — `note` included, since both motivating alerts were `note` with no `security_severity_level`, so a threshold would have reproduced the original silence. It also refuses the vacuous pass: an unanalysed ref, a missing language, an analysis over ten days old or one from a different commit than the run's are failures, and unreadable inputs exit 2 rather than 0. `--self-test` injects ten defects and requires each to be caught; CI runs it immediately before the gate. - Fix alert #896: `scripts/validate_playbooks.py` printed and called `sys.exit(2)` at import. `check_playbook_schema_parity.py` imports it under `except Exception`, which cannot catch `SystemExit`, so a broken environment killed that gate instead of producing its diagnostic. It now raises `ImportError`. - Correct the claim in `security.md`, `AGENTS.md` and the claim-to-gate matrix, which listed `codeql.yml` as the gate for an invariant it never checked. Alert #893 (`py/unused-global-variable`) was fixed independently by #811. * Install the gate job's test dependencies The gate itself is stdlib-only and ran fine; its unit-test step did not, because the job installed nothing. `validate_playbooks` reaches the real Playbook model transitively through httpx as well as pydantic, so both are needed for the two regression tests to run rather than fail — the same set `ci.yml`'s parity job installs. The import-error message no longer names pydantic specifically, since httpx was the dependency actually missing. * Fix the alert the new gate caught in its own test file The gate's first real run on this PR went red on #911, `py/implicit-string-concatenation-in-list` at `tests/test_codeql_alert_gate.py:292` — adjacent string literals inside the subprocess argument list, which is the missing-comma shape that rule exists to catch. `ruff format` had collapsed a deliberately two-line string onto one line, so the concatenation was introduced by formatting rather than written. Both inline subprocess programs are now module-level triple-quoted constants, which removes the concatenation and makes them readable as the programs they are. One more adjacent-literal pair inside the self-test's `cases` list is collapsed for the same reason. That the gate caught this before merge, on a merge commit it waited for, is the behaviour it was built for. --------- Co-authored-by: Beenu Arora <beenu@MacBook-Pro-3.local> |