M1: read-only local Ollama runtime collector #15

Merged
creatidy merged 18 commits from m1-ollama-runtime-collector into main 2026-09-05 08:29:38 +00:00
creatidy commented 2026-09-04 21:38:40 +00:00 (Migrated from github.com)

Closes #14

Summary

Simplifies the issue-scoped read-only Ollama runtime collector. Pure provider parsers remain unchanged in role and the collector still emits the v1 CapacitySnapshot plus LocalRuntime (provider=ollama, source=ollama_local). Healthy runtimes report windows: []; no quota, scarcity, percentage sentinel, generation, loading, pull/delete, benchmark, GPU, runtime/config mutation, or live provider call is included.

Implementation

  • Validates the explicit endpoint before I/O: plain HTTP on numeric loopback 127.0.0.1 or ::1, with omitted port canonicalized to 11434; unsafe names, ports, userinfo, query/fragment delimiters, whitespace, controls and non-root paths are rejected.
  • Performs at most three fixed GETs: /api/version, /api/tags, and conditional /api/ps; missing is reported only from a validated reachable listing.
  • Uses synchronous standard-library http.client.HTTPConnection with a finite socket timeout, one simple maximum response-body bound, safe status/transport normalization, strict UTF-8/JSON decoding, and normal finally cleanup. No raw sockets, connect_ex, readiness polling, worker threads, cancellation state, custom HTTP framing, private response subclass, proxy, or redirect handling.
  • Preserves independent configured/effective context semantics. Effective context requires validated positive /api/ps context_length and digest agreement with /api/tags; digest values never enter output.
  • Retains strict duplicate-key/non-finite/out-of-band-integer JSON rejection and safe redaction of response bodies, headers, endpoint values, paths and exception text.

Tests and limitations

The obsolete transport-mechanism tests were replaced by a focused fake-HTTPConnection contract harness covering endpoint policy, fixed paths, timeout propagation, statuses and transport failures, bounded bodies, cleanup, strict JSON and normalized parser semantics. Pure parser fixtures/tests remain.

  • Focused Ollama suite: 53 tests passed.
  • Full test phase: 453 tests ran; one unrelated pre-existing OpenAI subprocess test (test_oversized_line_with_secret_never_leaks) emitted a background feeder-thread traceback to stderr and failed. No Ollama test failed.
  • make typecheck / uv run basedpyright: 0 errors, 0 warnings, 0 notes.
  • git diff --check origin/main: clean; branch history is linear with no merge commit.
  • Current head: 3bfb715 (Simplify Ollama runtime transport).
  • This bounded pass removes approximately 3,700 net lines from production/tests/docs.

The effective-context populated value remains synthetic-fixture-tested only, and cross-version context_length stability plus CLI/status, freshness, selection, REST/MCP and other providers remain out of scope. PR #15 remains open and targets main.

Closes #14 ## Summary Simplifies the issue-scoped read-only Ollama runtime collector. Pure provider parsers remain unchanged in role and the collector still emits the v1 `CapacitySnapshot` plus `LocalRuntime` (`provider=ollama`, `source=ollama_local`). Healthy runtimes report `windows: []`; no quota, scarcity, percentage sentinel, generation, loading, pull/delete, benchmark, GPU, runtime/config mutation, or live provider call is included. ## Implementation - Validates the explicit endpoint before I/O: plain HTTP on numeric loopback `127.0.0.1` or `::1`, with omitted port canonicalized to `11434`; unsafe names, ports, userinfo, query/fragment delimiters, whitespace, controls and non-root paths are rejected. - Performs at most three fixed GETs: `/api/version`, `/api/tags`, and conditional `/api/ps`; missing is reported only from a validated reachable listing. - Uses synchronous standard-library `http.client.HTTPConnection` with a finite socket timeout, one simple maximum response-body bound, safe status/transport normalization, strict UTF-8/JSON decoding, and normal `finally` cleanup. No raw sockets, `connect_ex`, readiness polling, worker threads, cancellation state, custom HTTP framing, private response subclass, proxy, or redirect handling. - Preserves independent configured/effective context semantics. Effective context requires validated positive `/api/ps` `context_length` and digest agreement with `/api/tags`; digest values never enter output. - Retains strict duplicate-key/non-finite/out-of-band-integer JSON rejection and safe redaction of response bodies, headers, endpoint values, paths and exception text. ## Tests and limitations The obsolete transport-mechanism tests were replaced by a focused fake-`HTTPConnection` contract harness covering endpoint policy, fixed paths, timeout propagation, statuses and transport failures, bounded bodies, cleanup, strict JSON and normalized parser semantics. Pure parser fixtures/tests remain. - Focused Ollama suite: 53 tests passed. - Full test phase: 453 tests ran; one unrelated pre-existing OpenAI subprocess test (`test_oversized_line_with_secret_never_leaks`) emitted a background feeder-thread traceback to stderr and failed. No Ollama test failed. - `make typecheck` / `uv run basedpyright`: 0 errors, 0 warnings, 0 notes. - `git diff --check origin/main`: clean; branch history is linear with no merge commit. - Current head: `3bfb715` (`Simplify Ollama runtime transport`). - This bounded pass removes approximately 3,700 net lines from production/tests/docs. The effective-context populated value remains synthetic-fixture-tested only, and cross-version `context_length` stability plus CLI/status, freshness, selection, REST/MCP and other providers remain out of scope. PR #15 remains open and targets `main`.
Sign in to join this conversation.
No description provided.