Files
Linux_post_install/AgentsReport/builder/2026-09-06_f1-regex-fix.md
T
Your Name 0b5043a9f3
gates / consistency-and-conventions (push) Successful in 26s
fix: llama-server start breakage — version detection, flag-validation race, model dir resolution, user-bus pre-flight
User report after the llamacpp app install: 'installed llama.cpp unknown',
valid flags rejected (randomly per run), 'Model not found' for the HF
downloader's own layout, and a systemd user-bus failure over SSH. Detective
(real b10822 binary, FACT) found four independent causes:

- version: llama-server --version prints to STDERR; detect_llama_version's
  2>/dev/null swallowed it -> always 'unknown'. Now captures 2>&1 + accepts
  semver/build tokens (incl. build 1.2.3 edge)
- validation: printf|grep -q under pipefail -> SIGPIPE rc=141 race randomly
  rejected flags present in the 59 KB --help. Now pipe-less grep (no race);
  20x determinism regression test
- model resolution: resolve_model accepted files only, but the HF downloader
  creates <models>/<repo>/file.gguf dirs. Now expands a dir with exactly one
  *.gguf (never silently picks; multi-gguf lists + errs)
- port: llama.cpp default 8080 vs tool/adapter 8088; validation reliability
  means --port is now always pinned in the unit
- user bus: headless/SSH sessions lack XDG_RUNTIME_DIR -> ensure_user_bus in
  lib/common.sh pre-flights all three systemctl --user tools with remediation
  text; pos ai server --no-unit direct-run escape hatch (pidfile) for boxes
  with no bus
- find_llamacpp narrowed to llama-server/llama-server-cuda (bare 'server'
  fallback hazard); installer post-install sanity (version+help execute,
  symlink targets resolve)

Architect decisions DQ1-DQ6 recorded. Tester: 4 new regression files
(version-from-stderr, 25x flag-validation determinism, model dir expansion,
bus pre-flight + E2E) + 3 fixture updates; suite 16 files / 269 checks.

Verified: make gen idempotent; make check OK; make lint 0 FAIL, 0 WARN;
make test 269/269 (~49s); bash -n clean; git diff --check clean.
2026-09-06 09:25:52 -04:00

3.6 KiB
Raw Blame History

Builder report — F1 regex fix in bin/pos-ai-server

Date: 2026-09-06 · Builder · Objective: fix detect_llama_version regex so build 1.2.3 returns 1.2.3 not 1. File scope: bin/pos-ai-server ONLY. No commit.

TL;DR (status: IMPLEMENTED)

  • Root cause: grep -oE '[0-9]+\.[0-9]+\.[0-9]+|build [0-9]+|b[0-9]+' picks the LEFTMOST match; for input build 1.2.3, build [0-9]+ wins → build 1 → after ${version#build }1.
  • Fix: bin/pos-ai-server:86build [0-9]+(\.[0-9]+)* (full dotted tail consumed). Stripping and guarded behavior unchanged.
  • Gates: bash -n clean; make gen rc 0 with generated files byte-identical (sha256 before == after); make check OK; make lint 0 FAIL / 0 WARN.
  • Tests: tests/t-ai-llama-detect.sh (was failing on F1) now 9/9 PASS; tests/t-ai-server-validate.sh (Tester's F1 suite, real extracted function) 27/27 PASS.

Step 1: Read & confirm scope

  • Read AgentsReport/tester/2026-09-06_ai-server-tests.md (F1 finding: lines 9, 63).
  • Read bin/pos-ai-server (lines 8290).
  • Scope confirmed: touch bin/pos-ai-server only; do NOT touch tests/.

[PASS]

Step 2: Apply regex fix

  • bin/pos-ai-server:86: build [0-9]+build [0-9]+(\.[0-9]+)*.
  • Stripping (version="${version#build }") and guarded behavior (command -v guard + || true + unknown fallback) unchanged — per brief.

[PASS]

Step 3: Verification matrix (shipped regex evaluated against stub binaries)

  • version: 0.4.0-dev (build 10822, commit …) (stderr) → 0.4.0 PASS
  • build 1082210822 PASS
  • build 1.2.31.2.3 PASS (regression fixed)
  • b10822b10822 — see Decision Note below (brief's conditional 10822 not taken)
  • missing binary → unknown PASS
  • unreadable / non-matching output → unknown PASS
  • Additional: semver only (1.5.0)1.5.0 PASS (leftmost semver still wins)

Decision Note (b-token)

Brief lists b1082210822 "if your regex keeps a b-token", but also mandates "keep the same stripping logic" (${version#build } — strips only build , never b). The two are mutually exclusive. Resolution per the hard constraint: kept the b-token (matches existing comment: very old builds print no semver) and kept stripping identical → b10822 yields b10822. This is exactly what the Tester's own fixture asserts (tests/t-ai-server-validate.sh:118b10822), and t-ai-server-validate.sh passes 27/27 with the real extracted function.

[PASS]

Step 4: Gates

  • bash -n bin/pos-ai-server → clean
  • make gen → rc 0; sha256 of DOC/AGENT_Context_Project.md + completions/pos.bash identical before/after → NO output change (regex is code, not a GEN: block)
  • make check → OK
  • make lint → 0 FAIL, 0 WARN

[PASS]

Step 5: Tester-requested regression verification

  • ./tests/run-tests.sh t-ai-llama-detect.sh → PASS, 9/9 checks (was the failing test per Tester F1 finding; llama.cpp build 1.2.3 fixture now yields 1.2.3).
  • ./tests/run-tests.sh t-ai-server-validate.sh → PASS, 27/27 checks (real extracted detect_llama_version, incl. build 1082210822 and b10822b10822 fixtures).

[PASS]

Handoff

  • Status: IMPLEMENTED. Files changed: bin/pos-ai-server (single regex line, line 86). Git: NOT committed (per brief).
  • Note: the working tree already carried the pre-existing uncommitted F1F7 Builder changes plus 4 untracked Tester test files (per Tester report Step 6); none of that is mine.
  • Recommended next: Reviewer (independent gate + make test re-run). Separate track: F4 bus-gap fixture updates in 3 pre-existing DRY_RUN tests are already routed to Orchestrator — not touched here.