Skip to content

chore: development commands (Makefile) and read-only pre-commit checks - #46

Closed
pawelkiszczak wants to merge 5 commits into
rkinas:mainfrom
pawelkiszczak:chore/app-precommit
Closed

pawelkiszczak wants to merge 5 commits into
rkinas:mainfrom
pawelkiszczak:chore/app-precommit

Conversation

@pawelkiszczak

@pawelkiszczak pawelkiszczak commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Launching basal-serve, a benchmark, a batch run or a load test means assembling the command line by hand each time (mode, model, host / port, GGUF file, Ollama import, input / output files), and the repository has no commit checks for syntax errors, merge-conflict markers, private keys or broken TOML / YAML / JSON / JSONL files.

Change

  • Makefile (default target: help): setup, check, test, serve, bench, run, loadtest. MODE selects any of basal-serve's 16 modes (basal.server.MODES of 2.4.1: eager, fast, fast-nocompile, fast-exit, fp8, nvfp4, vllm, sglang, mlx, mlx-q8, mps, gguf, strix, tpu, ollama, llamacpp); MODEL (default: the CLIs' own), HOST (default 127.0.0.1), PORT, URL, INPUT, OUTPUT, GGUF, OLLAMA_MODEL and ARGS are configurable. Commands call the selected PYTHON directly, so they never sync the environment or replace the installed PyTorch build. MODE=gguf without GGUF, MODE=ollama without OLLAMA_MODEL, unreadable input files and an OUTPUT that is the INPUT file fail before anything is launched.
  • .pre-commit-config.yaml: seven pinned, read-only hooks: Ruff E9,F63,F7,F82 (syntax and critical errors only, no formatting), merge-conflict markers, private keys, TOML, YAML, JSON, and a standard-library JSONL checker (scripts/check_jsonl.py) for the bundled example files. Installing the Git hook is opt-in (pre-commit install); make check runs them without installing anything.
  • README: "Development commands" and "Development checks" sections (setup, hardware notes, examples, how hooks behave in Git worktrees).
  • Tests: tests/test_makefile.py (command construction for every mode, quoted values, early failures, an interpreter path with spaces; fake Python / uv executables, standard library only) and tests/test_check_jsonl.py.

App source, dependencies and uv.lock are unchanged.

Tests

On main @ b20f0f9 (2.4.1), Apple M4 Max, macOS:

Check Result
python3 -m unittest tests/test_makefile.py tests/test_check_jsonl.py 6 passed (36 subtests)
uv run pytest -q (whole suite) 776 passed, 44 skipped
uvx pre-commit==4.7.0 validate-config passed
uvx pre-commit==4.7.0 run --all-files 6 of 7 hooks pass; Ruff reports one finding in existing code (below)
make serve MODE=mlx MODEL=Remek/basal-2.0-mini-MLX-8bit HOST=127.0.0.1 PORT=8771 basal-serve ready in 1 s
make run PORT=8771 INPUT=basal/examples/questions.jsonl OUTPUT=… 20 of 20 items answered, 0 errors

Ruff finding in existing code (not changed here)

F821 Undefined name kpos at basal/gemma4.py:471, in Gemma4Forward._prefix: ctx=(kv, kpos) if kv else None reads kpos, which is first assigned at the end of the loop body (line 483). At runtime it is always defined when read (kv is empty in the first part, and kpos is set before kv can be non-empty), so this is not a crash, but make check fails on it until the name is defined before the loop, e.g. kv, bufs, kpos = {}, {}, {}. Left to you, since it touches the engine.

Not done / not tested

  • No CUDA, Windows or Linux run: make serve / bench for the CUDA modes (fast, fp8, nvfp4, fast-exit, vllm, sglang), gguf, ollama, llamacpp, strix and tpu are covered by the command-construction tests only.
  • make bench and make loadtest were not run against a real server (command construction tests only).
  • The Git hook was not installed in a working clone (pre-commit install is opt-in and documented).
  • No CI: the repository has none, and this PR adds none.

Summary by Sourcery

Provide configurable development commands and opt-in read-only repository checks without changing application dependencies or source behavior.

New Features:

  • Add Makefile commands for environment setup, validation, testing, serving, benchmarking, batch runs, and load testing with configurable runtime options.
  • Add opt-in read-only pre-commit checks for critical Python errors, merge conflicts, private keys, and TOML, YAML, JSON, and JSONL syntax.

Enhancements:

  • Add early validation for backend requirements, input files, and conflicting input/output paths.
  • Document development commands, hardware considerations, check behavior, and worktree implications.

Documentation:

  • Document the new development workflow, command usage, configuration variables, and pre-commit checks in the README.

Tests:

  • Add standard-library tests covering Makefile command construction, validation failures, quoting, interpreter paths, and JSONL validation.

sglang, strix, tpu and llamacpp were added to basal-serve after this
branch was first written; the help text and the serving-mode test
follow basal.server.MODES of 2.4.1.
@sourcery-ai

sourcery-ai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Adds reproducible, configurable Makefile commands and opt-in pinned pre-commit checks without changing application code or dependencies, with documentation and standard-library coverage for command construction, early validation, and strict JSONL syntax checking.

Sequence diagram for validated batch execution

sequenceDiagram
    participant Developer
    participant Make as Makefile
    participant Python as PYTHON
    participant Server as basal.server
    participant Runner as basal.run

    Developer->>Make: make serve MODE=... HOST=... PORT=...
    Make->>Make: check-backend
    Make->>Python: -m basal.server
    Python->>Server: start with backend and host options
    Server-->>Developer: server ready
    Developer->>Make: make run INPUT=... OUTPUT=...
    Make->>Make: check-input
    Make->>Python: -m basal.run --url --input --output
    Python->>Runner: process batch requests
    Runner-->>Developer: write output file
Loading

Flow diagram for Makefile development commands

flowchart TD
    Start[make target] --> Validate{Validation needed}
    Validate -->|backend options| Backend[check-backend]
    Validate -->|input and output files| Input[check-input]
    Validate -->|none| Launch
    Backend --> Launch[Invoke selected PYTHON module]
    Input --> Launch
    Launch --> Serve[basal.server]
    Launch --> Bench[basal.bench]
    Launch --> Run[basal.run]
    Launch --> Loadtest[basal.loadtest]
Loading

Flow diagram for read-only development checks

flowchart LR
    Check[make check] --> Precommit[pre-commit run --all-files]
    Precommit --> Ruff[Ruff critical Python errors]
    Precommit --> Files[Conflict markers and private keys]
    Precommit --> Structured[TOML YAML JSON checks]
    Precommit --> JSONL[check_jsonl.py]
    Ruff --> Result[Pass or report findings]
    Files --> Result
    Structured --> Result
    JSONL --> Result
Loading

File-Level Changes

Change Details Files
Add configurable Makefile wrappers for setup, validation, testing, serving, benchmarking, batch runs, and load testing.
  • Define defaults and environment-overridable parameters for Python, backend mode, model, networking, input/output paths, and extra CLI arguments.
  • Invoke the selected interpreter directly and construct safely quoted commands for all supported server modes and client workflows.
  • Add early checks for required GGUF/Ollama settings, readable files, and input/output path conflicts.
Makefile
Introduce opt-in, read-only pre-commit validation for source and data-file integrity.
  • Pin pre-commit hook and Ruff versions while limiting Ruff to critical error rules without autofixing.
  • Check merge conflicts, private keys, TOML, YAML, JSON, and strict JSONL syntax.
  • Implement a standard-library JSONL checker that skips blank lines, rejects non-standard constants, reports file/line errors, and never rewrites files.
.pre-commit-config.yaml
scripts/check_jsonl.py
Document the development workflow and operational constraints for the new commands and checks.
  • Explain environment setup, hardware-specific extras, command examples, configurable variables, quoting, and dry-run inspection.
  • Document check coverage, opt-in hook installation, isolated execution, and shared Git worktree behavior.
README.md
Add standard-library tests covering command generation, validation behavior, and JSONL checking.
  • Exercise every server mode, defaults, quoted values, custom interpreter paths containing spaces, and command argument propagation.
  • Verify required-option, file, and input/output conflict failures occur before launch.
  • Test valid, invalid, Unicode, blank-line, multi-file, and non-standard JSONL inputs without file modification.
tests/test_makefile.py
tests/test_check_jsonl.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai 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.

Hey - I've found 7 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="Makefile" line_range="39" />
<code_context>
+	"$$UV" tool run pre-commit==4.7.0 run --all-files
+
+test:
+	"$$PYTHON" -m pytest $(ARGS)
+
+check-backend:
</code_context>
<issue_to_address>
**Extra options execute shell commands**

When a wrapper or CI job forwards an attacker-controlled `ARGS` value, the recipe expands `ARGS` directly into shell command text, so shell metacharacters in that value run arbitrary commands alongside the requested target; an attacker who can supply `ARGS` through a wrapper or CI input gets command execution as the make process.

Do not interpolate untrusted `ARGS` as shell text; pass additional options through a safely encoded argument vector or accept only validated, trusted values.

Also at `Makefile:53`, `Makefile:58`, `Makefile:62`, `Makefile:66`.
</issue_to_address>

### Comment 2
<location path="Makefile" line_range="7" />
<code_context>
+EXTRAS ?= test
+MODEL ?= Remek/basal-1.0-4.5B
+MODE ?=
+HOST ?= 0.0.0.0
+PORT ?= 8000
+URL ?= http://127.0.0.1:$(PORT)/v1/systemone
</code_context>
<issue_to_address>
**Server listens on every interface**

When the machine running `make serve` is reachable by other network peers, the `serve` target passes the default `0.0.0.0` host to an unauthenticated server, allowing network peers to submit inference requests and consume the machine's backend resources.

Default the Make target to `127.0.0.1` and require an explicit host override to listen on external interfaces.

Also at `Makefile:50`.
</issue_to_address>

### Comment 3
<location path="Makefile" line_range="66" />
<code_context>
+	"$$PYTHON" -m basal.bench --model "$$MODEL" \
+	  $(if $(MODE),--modes "$$MODE") $(if $(GGUF),--gguf "$$GGUF") \
+	  $(if $(OLLAMA_MODEL),--ollama-model "$$OLLAMA_MODEL") \
+	  $(if $(INPUT),--questions "$$INPUT") $(if $(OUTPUT),--out "$$OUTPUT") $(ARGS)
+
+run: check-input
</code_context>
<issue_to_address>
**Load-test output leaks URL credentials**

When the configured URL contains credentials or a signed token and the logs or output artifact are visible to other users, `basal.loadtest` records the configured URL verbatim in its results and prints it to stdout; credentials or signed query tokens in `URL` therefore appear in logs and any `OUTPUT` artifact, where other users can read them.

Redact URL user information and sensitive query parameters before printing or writing load-test results.
</issue_to_address>

### Comment 4
<location path="Makefile" line_range="62" />
<code_context>
+
+run: check-input
+	@test -n "$$INPUT" && test -n "$$OUTPUT" || { echo 'run requires INPUT=<file> and OUTPUT=<file>' >&2; exit 1; }
+	"$$PYTHON" -m basal.run --url "$$URL" --input "$$INPUT" --output "$$OUTPUT" $(ARGS)
+
+loadtest: check-input
</code_context>
<issue_to_address>
**Batch runs overwrite their input**

When `INPUT` and `OUTPUT` refer to the same file, `basal.run.run` reads the questions and then opens the output with mode `w`, replacing the source JSONL with answer rows; the benchmark and load-test recipes likewise pass both paths without checking that they differ, so the source dataset is lost.

Reject input/output paths that resolve to the same file before launching each command.

Also at `Makefile:58`, `Makefile:66`.
</issue_to_address>

### Comment 5
<location path=".pre-commit-config.yaml" line_range="16" />
<code_context>
+    hooks:
+      - id: ruff-check
+        types_or: [python, pyi]
+        args: [--select, 'E9,F63,F7,F82', --target-version, py310, --no-fix, --no-cache]
+
+  - repo: local
</code_context>
<issue_to_address>
**Default checks fail on an existing finding**

When the existing F821 in `basal/gemma4.py:471` remains, ruff selects `F82` and reports the undefined `kpos` in `Gemma4Forward._prefix`, so `make check` exits nonzero even when the files changed by the PR are clean.

Fix the existing `F821` or configure the hook so it does not make the default check fail on this finding.
</issue_to_address>

### Comment 6
<location path="scripts/check_jsonl.py" line_range="15" />
<code_context>
+                    if not line.strip():  # The batch runner also skips blank lines.
+                        continue
+                    try:
+                        json.loads(line)
+                    except ValueError as error:
+                        print(f"{filename}:{number}: {error}")
</code_context>
<issue_to_address>
**Invalid JSON values pass validation**

When a JSONL line contains `NaN`, `Infinity`, or `-Infinity`, `json.loads` accepts these non-standard constants by default, so `check_jsonl.py` reports the line as valid and strict JSON consumers reject the file.

Reject non-standard constants when parsing each JSONL line.
</issue_to_address>

### Comment 7
<location path="Makefile" line_range="5" />
<code_context>
+PYTHON ?= .venv/bin/python
+UV ?= uv
+EXTRAS ?= test
+MODEL ?= Remek/basal-1.0-4.5B
+MODE ?=
+HOST ?= 0.0.0.0
</code_context>
<issue_to_address>
**Make targets use a different checkpoint**

When `MODEL` is not overridden, `serve` and `bench` pass `MODEL` explicitly, overriding both CLIs’ `Remek/basal-1.5-4.5B` default with `Remek/basal-1.0-4.5B`, so users get a different checkpoint and benchmark defaults than when invoking the CLIs directly.

Set the Makefile’s default `MODEL` to the CLIs’ `Remek/basal-1.5-4.5B` default.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread Makefile
"$$UV" tool run pre-commit==4.7.0 run --all-files

test:
"$$PYTHON" -m pytest $(ARGS)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · Extra options execute shell commands

When a wrapper or CI job forwards an attacker-controlled ARGS value, the recipe expands ARGS directly into shell command text, so shell metacharacters in that value run arbitrary commands alongside the requested target; an attacker who can supply ARGS through a wrapper or CI input gets command execution as the make process.

Do not interpolate untrusted ARGS as shell text; pass additional options through a safely encoded argument vector or accept only validated, trusted values.

Also at Makefile:53, Makefile:58, Makefile:62, Makefile:66.

Prompt for AI agents
In `Makefile` at line 39:

**Extra options execute shell commands**

When a wrapper or CI job forwards an attacker-controlled `ARGS` value, the recipe expands `ARGS` directly into shell command text, so shell metacharacters in that value run arbitrary commands alongside the requested target; an attacker who can supply `ARGS` through a wrapper or CI input gets command execution as the make process.

Do not interpolate untrusted `ARGS` as shell text; pass additional options through a safely encoded argument vector or accept only validated, trusted values.

Also at `Makefile:53`, `Makefile:58`, `Makefile:62`, `Makefile:66`.

Comment thread Makefile Resolved
Comment thread Makefile

loadtest: check-input
"$$PYTHON" -m basal.loadtest --url "$$URL" \
$(if $(INPUT),--questions "$$INPUT") $(if $(OUTPUT),--out "$$OUTPUT") $(ARGS)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Load-test output leaks URL credentials

When the configured URL contains credentials or a signed token and the logs or output artifact are visible to other users, basal.loadtest records the configured URL verbatim in its results and prints it to stdout; credentials or signed query tokens in URL therefore appear in logs and any OUTPUT artifact, where other users can read them.

Redact URL user information and sensitive query parameters before printing or writing load-test results.

Prompt for AI agents
In `Makefile` at line 66:

**Load-test output leaks URL credentials**

When the configured URL contains credentials or a signed token and the logs or output artifact are visible to other users, `basal.loadtest` records the configured URL verbatim in its results and prints it to stdout; credentials or signed query tokens in `URL` therefore appear in logs and any `OUTPUT` artifact, where other users can read them.

Redact URL user information and sensitive query parameters before printing or writing load-test results.

Comment thread Makefile Resolved
Comment thread .pre-commit-config.yaml
hooks:
- id: ruff-check
types_or: [python, pyi]
args: [--select, 'E9,F63,F7,F82', --target-version, py310, --no-fix, --no-cache]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · Default checks fail on an existing finding

When the existing F821 in basal/gemma4.py:471 remains, ruff selects F82 and reports the undefined kpos in Gemma4Forward._prefix, so make check exits nonzero even when the files changed by the PR are clean.

Fix the existing F821 or configure the hook so it does not make the default check fail on this finding.

Prompt for AI agents
In `.pre-commit-config.yaml` at line 16:

**Default checks fail on an existing finding**

When the existing F821 in `basal/gemma4.py:471` remains, ruff selects `F82` and reports the undefined `kpos` in `Gemma4Forward._prefix`, so `make check` exits nonzero even when the files changed by the PR are clean.

Fix the existing `F821` or configure the hook so it does not make the default check fail on this finding.

Comment thread scripts/check_jsonl.py Resolved
Comment thread Makefile Resolved
- make serve listens on 127.0.0.1; HOST=0.0.0.0 is an explicit choice
- MODEL empty: serve and bench keep the CLIs' own default model
  instead of a second, diverging default
- run, bench and loadtest refuse an OUTPUT that is the INPUT file
  (same path or same file under another spelling)
- check_jsonl rejects NaN, Infinity and -Infinity, which json.loads
  accepts and strict JSON readers do not
- README: the new defaults; ARGS runs as shell text, trusted input only
@pawelkiszczak

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Addressed in d5cccff:

Finding Change
Server listens on every interface (Makefile:7) HOST defaults to 127.0.0.1; HOST=0.0.0.0 has to be chosen explicitly (help text and README say what it exposes)
Make targets use a different checkpoint (Makefile:5) MODEL is empty by default and --model is passed only when it is set, so serve and bench keep the CLIs' own default model and cannot drift from it
Batch runs overwrite their input (Makefile:62, :58, :66) check-input refuses an OUTPUT that is the INPUT file, as the same string or the same file under another spelling (-ef), before anything is launched; tested for run, bench and loadtest
Invalid JSON values pass validation (scripts/check_jsonl.py:15) json.loads(..., parse_constant=...) rejects NaN, Infinity and -Infinity with the file and line; tested

Not changed, with the reason:

  • Extra options execute shell commands (ARGS): ARGS is appended as shell text on purpose, so options with quoted values work (ARGS='--name "Friendly server"'). Make variables come from whoever runs make, the same trust as the command line itself. The README now says to pass only trusted text; a wrapper or CI job that forwards untrusted input should call the CLIs directly instead.
  • Default checks fail on an existing finding (F821 kpos in basal/gemma4.py:471): this is in the engine, which this PR leaves untouched, and as described in the PR it is not a crash (kpos is set at the end of each part, before kv can be non-empty). One line before the loop (kv, bufs, kpos = {}, {}, {}) makes make check pass; left to you.
  • Load-test output leaks URL credentials: that is basal-loadtest's existing behaviour (it records --url as given), not something the Makefile adds; the default URL has no credentials.

Re-run on main @ b20f0f9: python3 -m unittest tests/test_makefile.py tests/test_check_jsonl.py 6 passed; uv run pytest -q 776 passed, 44 skipped; pre-commit run --all-files passes except the F821 above; make run INPUT=x OUTPUT=./x stops with OUTPUT must not be the INPUT file.

@pawelkiszczak
pawelkiszczak deleted the chore/app-precommit branch October 28, 2026 00:07
@pawelkiszczak
pawelkiszczak restored the chore/app-precommit branch October 28, 2026 09:41
@pawelkiszczak pawelkiszczak reopened this Oct 28, 2026

@sourcery-ai sourcery-ai 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.

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".pre-commit-config.yaml" line_range="16" />
<code_context>
+    hooks:
+      - id: ruff-check
+        types_or: [python, pyi]
+        args: [--select, 'E9,F63,F7,F82', --target-version, py310, --no-fix, --no-cache]
+
+  - repo: local
</code_context>
<issue_to_address>
**Checks fail on existing lint error**

When `make check` runs against the repository contents in this PR, the all-files Ruff hook selects F821 through F82 and reports the existing `kpos` reference in `basal/gemma4.py`, so pre-commit exits nonzero and `make check` fails.

Fix the existing `kpos` reference or configure the hook so the new check passes on this tree.

Also at `Makefile:37`.
</issue_to_address>

### Comment 2
<location path="Makefile" line_range="61" />
<code_context>
+      - id: check-toml
+      - id: check-yaml
+      - id: check-json
+
+  - repo: https://github.com/astral-sh/ruff-pre-commit
+    rev: v0.17.1
</code_context>
<issue_to_address>
**Input data gets truncated**

When `ARGS` supplies a later output option equal to the input path, including a later input/output pair that selects the same file, the Make recipes append `ARGS` after the checked file options, so the CLI uses the later values and opens the input as its output, truncating the source file.

Prevent `ARGS` from overriding the checked input and output options, or validate the effective options after applying `ARGS`.

Also at `Makefile:60`, `Makefile:64`, `Makefile:68`.
</issue_to_address>

### Comment 3
<location path="scripts/check_jsonl.py" line_range="17" />
<code_context>
+        try:
+            with open(filename, encoding="utf-8") as source:
+                for number, line in enumerate(source, 1):
+                    if not line.strip():  # The batch runner also skips blank lines.
+                        continue
+                    try:
</code_context>
<issue_to_address>
**Invalid JSONL passes validation**

When a JSONL file contains a line consisting only of non-JSON Unicode whitespace, `line.strip()` treats Unicode whitespace such as a non-breaking space as blank, so the checker skips that line instead of passing it to `json.loads`; a file containing it passes the advertised JSONL syntax check despite not being valid JSON whitespace.

Check for blank lines using only JSON whitespace characters (`space`, tab, CR, and LF) before parsing.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread .pre-commit-config.yaml
hooks:
- id: ruff-check
types_or: [python, pyi]
args: [--select, 'E9,F63,F7,F82', --target-version, py310, --no-fix, --no-cache]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Checks fail on existing lint error

When make check runs against the repository contents in this PR, the all-files Ruff hook selects F821 through F82 and reports the existing kpos reference in basal/gemma4.py, so pre-commit exits nonzero and make check fails.

Fix the existing kpos reference or configure the hook so the new check passes on this tree.

Also at Makefile:37.

Prompt for AI agents
In `.pre-commit-config.yaml` at line 16:

**Checks fail on existing lint error**

When `make check` runs against the repository contents in this PR, the all-files Ruff hook selects F821 through F82 and reports the existing `kpos` reference in `basal/gemma4.py`, so pre-commit exits nonzero and `make check` fails.

Fix the existing `kpos` reference or configure the hook so the new check passes on this tree.

Also at `Makefile:37`.

Comment thread Makefile
$(if $(MODE),--modes "$$MODE") $(if $(GGUF),--gguf "$$GGUF") \
$(if $(OLLAMA_MODEL),--ollama-model "$$OLLAMA_MODEL") \
$(if $(INPUT),--questions "$$INPUT") $(if $(OUTPUT),--out "$$OUTPUT") $(ARGS)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · Input data gets truncated

When ARGS supplies a later output option equal to the input path, including a later input/output pair that selects the same file, the Make recipes append ARGS after the checked file options, so the CLI uses the later values and opens the input as its output, truncating the source file.

Prevent ARGS from overriding the checked input and output options, or validate the effective options after applying ARGS.

Also at Makefile:60, Makefile:64, Makefile:68.

Prompt for AI agents
In `Makefile` at line 61:

**Input data gets truncated**

When `ARGS` supplies a later output option equal to the input path, including a later input/output pair that selects the same file, the Make recipes append `ARGS` after the checked file options, so the CLI uses the later values and opens the input as its output, truncating the source file.

Prevent `ARGS` from overriding the checked input and output options, or validate the effective options after applying `ARGS`.

Also at `Makefile:60`, `Makefile:64`, `Makefile:68`.

Comment thread scripts/check_jsonl.py
try:
with open(filename, encoding="utf-8") as source:
for number, line in enumerate(source, 1):
if not line.strip(): # The batch runner also skips blank lines.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Invalid JSONL passes validation

When a JSONL file contains a line consisting only of non-JSON Unicode whitespace, line.strip() treats Unicode whitespace such as a non-breaking space as blank, so the checker skips that line instead of passing it to json.loads; a file containing it passes the advertised JSONL syntax check despite not being valid JSON whitespace.

Check for blank lines using only JSON whitespace characters (space, tab, CR, and LF) before parsing.

Prompt for AI agents
In `scripts/check_jsonl.py` at line 17:

**Invalid JSONL passes validation**

When a JSONL file contains a line consisting only of non-JSON Unicode whitespace, `line.strip()` treats Unicode whitespace such as a non-breaking space as blank, so the checker skips that line instead of passing it to `json.loads`; a file containing it passes the advertised JSONL syntax check despite not being valid JSON whitespace.

Check for blank lines using only JSON whitespace characters (`space`, tab, CR, and LF) before parsing.

@pawelkiszczak
pawelkiszczak deleted the chore/app-precommit branch October 28, 2026 10:05
rkinas added a commit that referenced this pull request Nov 2, 2026
rkinas added a commit that referenced this pull request Nov 2, 2026
rkinas added a commit that referenced this pull request Nov 2, 2026
rkinas added a commit that referenced this pull request Nov 2, 2026
…z Koryto)

Without .github/dependabot.yml: automatic dependency pull requests are the maintainer's call. The
conflict in basal/gemma4.py keeps 2.5's kpos fix from #46 (None until the first keys).
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.

1 participant