feat(remediation): switch worker to OpenCode Go longcat-2.5-preview-free #329

Merged
nimmo merged 4 commits from feature/328-opencode-go-remediation-worker into main 2026-10-14 15:20:09 +01:00
Owner

Refs #328.

Summary

Switches the automated update remediation worker from local Ollama (qwen3.6:35b-a3b-q8_0) to OpenCode Go with model longcat-2.5-preview-free.

Motivation

The local quantized 35B model frequently struggled with structured JSON compliance or timed out under the 600s deadline, resulting in ambiguous diagnosis failures (such as in Issue #327). longcat-2.5-preview-free provides 1M context, full temperature tuning (temperature: 0), strict JSON compliance, fast response times (~3-4s), and zero token cost on the user's OpenCode Go subscription.

Changes

  • Policy (remediation/nova-policy.json): Configured providerId: "opencode-go", id: "longcat-2.5-preview-free", 1M context tokens.
  • Sandbox auth (scripts/nixos_update_remediation/model.py): Injected filtered runner credentials (opencode, opencode-go) into /home/remediation/.local/share/opencode/auth.json inside Bubblewrap while strictly filtering out unrelated host credentials.
  • Controller contract (scripts/nixos_update_remediation/core.py & cli.py): Updated deterministic model validation.
  • Documentation (docs/auto-update-remediation.md): Updated worker model specifications.
  • Tests (tests/nixos-update-remediation-regressions.sh & tests/nixos-update-remediation-integration.py): Updated assertions and verified test suite passes.

Validation

  • Live Bubblewrap sandbox execution on Nova runner (PONG verified).
  • ./tests/nixos-update-remediation-regressions.sh passed.
  • ./tests/nixos-pin-lifecycle-regressions.sh passed.
  • nix flake check passed.
  • python3 -m py_compile and shellcheck passed.
Refs #328. ### Summary Switches the automated update remediation worker from local Ollama (`qwen3.6:35b-a3b-q8_0`) to OpenCode Go with model `longcat-2.5-preview-free`. ### Motivation The local quantized 35B model frequently struggled with structured JSON compliance or timed out under the 600s deadline, resulting in ambiguous diagnosis failures (such as in Issue #327). `longcat-2.5-preview-free` provides 1M context, full temperature tuning (`temperature: 0`), strict JSON compliance, fast response times (~3-4s), and zero token cost on the user's OpenCode Go subscription. ### Changes - **Policy (`remediation/nova-policy.json`)**: Configured `providerId: "opencode-go"`, `id: "longcat-2.5-preview-free"`, 1M context tokens. - **Sandbox auth (`scripts/nixos_update_remediation/model.py`)**: Injected filtered runner credentials (`opencode`, `opencode-go`) into `/home/remediation/.local/share/opencode/auth.json` inside Bubblewrap while strictly filtering out unrelated host credentials. - **Controller contract (`scripts/nixos_update_remediation/core.py` & `cli.py`)**: Updated deterministic model validation. - **Documentation (`docs/auto-update-remediation.md`)**: Updated worker model specifications. - **Tests (`tests/nixos-update-remediation-regressions.sh` & `tests/nixos-update-remediation-integration.py`)**: Updated assertions and verified test suite passes. ### Validation - Live Bubblewrap sandbox execution on Nova runner (`PONG` verified). - `./tests/nixos-update-remediation-regressions.sh` passed. - `./tests/nixos-pin-lifecycle-regressions.sh` passed. - `nix flake check` passed. - `python3 -m py_compile` and `shellcheck` passed.
feat(remediation): switch worker to OpenCode Go longcat-2.5-preview-free
All checks were successful
Build and Push Attic Cache / test (pull_request) Successful in 1m26s
Build and Push Attic Cache / build (pull_request) Has been skipped
Build and Push Attic Cache / pin-lifecycle (pull_request) Has been skipped
Build and Push Attic Cache / remediate (pull_request) Has been skipped
Build and Push Attic Cache / notify-remediation (pull_request) Has been skipped
Build and Push Attic Cache / record-remediation-notify-failure (pull_request) Has been skipped
AI pull-request review / review (pull_request) Successful in 14m25s
c271a025cd
Refs #328. Update the remediation policy, sandbox auth management, controller verification, and regression tests to use OpenCode Go with longcat-2.5-preview-free.
clankbot left a comment

Automated code review

Reviewed commit: c271a025cd1fe7e340813e00cb6b1e6bbe21f03c

Verdict: Requires further work

Resolve the blocking or important findings and investigate failed deterministic checks before merging.

Overall assessment

The model/provider swap is internally consistent across the policy, core.load_policy, cli.verify_contract, the regression jq gate, and the integration fixture: all move to longcat-2.5-preview-free / opencode-go together, and remediation/worker-prompt.md contains no model- or provider-specific text that would now be stale (grep for qwen/ollama/model/opencode in that file returns no matches). The only substantive new behaviour is the credential bridge in model.py (lines 595-612), which copies a hard-coded subset of the runner's ~/.local/share/opencode/auth.json into the sandbox home so the previously credential-free worker can authenticate to OpenCode Go. That path is fail-open (except Exception: pass, plus a silent skip when the filtered dict is empty), admits one key beyond the policy's providerId, is not covered by the hermetic fixtures, and is not described in the boundary paragraph of docs/auto-update-remediation.md. I could not run nix flake check, the regression suites, or inspect the live Nova runner, so provisioning of the runner credential is raised as a question rather than asserted.

Blocking findings

None.

Important findings

  • Credential bridge is fail-open: a missing, unparseable, or unwritable provider credential is indistinguishable from a model failure (scripts/nixos_update_remediation/model.py:611; high confidence)
    The new block (model.py:595-612) wraps the read, json.load, and atomic_write_json in try: ... except Exception: pass, and additionally writes nothing when the filtered dict is empty (if sandbox_auth: at line 607). atomic_write_json (core.py:181) raises ControllerError, which that bare handler also swallows. Unlike the previous loopback Ollama worker, opencode-go is an authenticated provider (secrets/README.md:232 documents opencode-go-api-key being merged into auth.json as the opencode-go provider entry), so an absent key now yields an unauthenticated call whose only downstream signal is the generic post-run error. Every other boundary check in this controller is fail-closed with a specific reason string.
    Impact: An authentication/configuration regression is reported as an ambiguous model failure in the published diagnosis and incident state, so the fleet cannot separate a credential fault from a genuine model failure, and the fail-closed contract loses its specific cause.
    Suggested fix: Make the credential path fail closed: raise a ControllerError naming the cause (missing opencode-go key in the runner's auth.json, unparseable file, or failed sandbox write) instead of swallowing the exception, and treat an empty filtered credential set for the authenticated policy["model"]["providerId"] as an explicit error rather than a silent no-op.

Suggestions

  • Credential filter is hard-coded to ["opencode", "opencode-go"] instead of the policy's providerId (scripts/nixos_update_remediation/model.py:604; medium confidence)
    The filter admits every key in the literal list ["opencode", "opencode-go"], while remediation/nova-policy.json selects only providerId: "opencode-go". modules/profiles/ai-runtime.nix:348-354 shows the activation writing openrouter, opencode-go, and pangolin-lyra entries into auth.json (correctly excluded), so the extra admitted key opencode is not produced by that activation and is not the provider the policy selects. The copy is written into the writable bind-mounted sandbox home (--bind str(home) /home/remediation, with --share-net enabled), and the published model text fields pass only through sanitise_plain_text (core.py:187), which strips control characters and collapses whitespace but does not redact credential-like values.
    Impact: More auth/subscription material than the selected provider needs is reachable from a model-capable, network-enabled sandbox, and nothing in the controller would redact a credential echoed into the published diagnosis or rationale.
    Suggested fix: Filter to policy["model"]["providerId"] only (or state in the policy/docs why the opencode account entry is additionally required for an opencode-go request), so the admitted credential set is derived from the reviewed policy rather than a literal list.

  • New credential bridge has no fixture coverage and reads the host's real credentials during the documented hermetic test run (tests/nixos-update-remediation-integration.py:785; medium confidence)
    assert_clean_model_boundary asserts only on recorded env keys and the generated OpenCode config; nothing asserts that auth.json exists at <sandbox home>/.local/share/opencode/auth.json, that it is filtered, or that unrelated keys are excluded. The fixture invokes the controller with controller_env = os.environ.copy() (test line 1033), so Path.home() in model.py:597 resolves to the machine running the test, while docs/auto-update-remediation.md:175 states these integration tests are hermetic and use fake OpenCode/Bubblewrap/Nix/Tea.
    Impact: A regression in the credential bridge (wrong key filter, no file written, wrong sandbox path) would pass the current suite, and the fixture's behaviour currently varies with the host it is run on.
    Suggested fix: Have the fixture supply a synthetic auth.json under a fixture-controlled HOME containing decoy keys (openrouter, pangolin-lyra) plus the permitted provider key, and assert the sandbox copy exists and contains only the permitted key.

  • Reviewed boundary paragraph in the docs does not state that a provider credential is now admitted to the sandbox (docs/auto-update-remediation.md:46; medium confidence)
    The edited sentence still enumerates only what the subprocess does not receive ("no Attic/ntfy/deployment secrets, Forgejo or checkout credentials, normal OpenCode config, MCP servers, ..."), and the only related edit deletes the word auth from "normal OpenCode auth/config". Nothing in the paragraph states that model.py:595-612 now copies the runner's filtered opencode/opencode-go credential into the sandbox home, which is the one credential material the model-capable job now holds.
    Impact: This paragraph is the reviewed contract for the worker boundary, so a reader would conclude no credential reaches the sandbox and mis-assess the isolation guarantee and the credential's publication risk.
    Suggested fix: State the credential bridge explicitly in this paragraph: which keys are copied, from which host path, and that the copy is confined to the sandbox home and never published.

Tests and validation

  • No configured deterministic checks.

Questions

  • Where is the Nova runner's ~/.local/share/opencode/auth.json provisioned? docs/nova-remote-builder.md describes Nova as a Fedora host not registered in the flake, and the opencode-go entry is normally written by the home-manager activation in modules/profiles/ai-runtime.nix:348-354; potential/nova/default.nix contains no ai-runtime or opencode profile. Please confirm the remediate job's HOME actually contains an opencode-go key, since the code silently proceeds without it.
  • Should the generated provider definition keep forwarding "npm": "@ai-sdk/openai-compatible" from remediation/nova-policy.json while omitting options.baseURL (the policy no longer carries baseUrl, and opencode_config now emits that key only conditionally)? OpenCode's provider/auth registry is not in this checkout, so I cannot confirm that an opencode-go entry without a baseURL resolves to the correct endpoint and auth flow.
  • Is the opencode auth entry required for an opencode-go request, or is the opencode-go key alone sufficient? The filter admits both.
  • contextTokens is now 1000000 while limits.modelEventBytes (8 MiB), limits.incidentBytes (64 KiB), and the evidence bounds are unchanged. Is the larger context intended only to permit larger incident evidence, or should those bounds be raised to use it?

Review limitations

  • I did not run nix flake check, tests/nixos-update-remediation-regressions.sh, tests/nixos-update-remediation-integration.py, or any repository code; the review container has no Nix, and the PR's claims that the suites pass and that live Bubblewrap execution returned PONG are unverified PR text.
  • The live Nova runner state is not supplied: I cannot confirm that Path.home() resolves to a home containing an opencode-go entry, nor the file's ownership/mode as seen by the sandbox uid 65534.
  • OpenCode's provider/auth registry and its opencode-go/opencode provider definitions are not in this checkout, so I cannot verify the generated provider/models config resolves to a working authenticated endpoint for longcat-2.5-preview-free.
  • scripts/nova-remediation-benchmark.py, benchmarks/nova-remediation/, and tests/nova-remediation-benchmark.sh are referenced by .forgejo/workflows/attic-cache.yml path filters but are absent from this checkout, so I could not assess whether they still assume the previous local model.
  • Only the supplied diff files and their surrounding code were inspected; unchanged code outside scripts/nixos_update_remediation/, its tests, and the remediation docs was not assessed for defects, and no finding outside the changed files is reported.

Diff coverage

  • docs/auto-update-remediation.md: reviewed — included in a context-limited batch
  • remediation/nova-policy.json: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/cli.py: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/core.py: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/model.py: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/publication.py: reviewed — included in a context-limited batch
  • tests/nixos-update-remediation-integration.py: reviewed — included in a context-limited batch
  • tests/nixos-update-remediation-regressions.sh: reviewed — included in a context-limited batch
Review metadata
  • Reviewer: forgejo-ai-review v1
  • Model: strata/strata
  • Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/hermes-fleet-ssh.md, docs/nova-remote-builder.md, README.md
  • Commits considered: 1
  • Previous automated review: none found
  • Findings: 4
<!-- forgejo-ai-review:v1 --> ## Automated code review Reviewed commit: `c271a025cd1fe7e340813e00cb6b1e6bbe21f03c` ## Verdict: Requires further work Resolve the blocking or important findings and investigate failed deterministic checks before merging. ### Overall assessment The model/provider swap is internally consistent across the policy, `core.load_policy`, `cli.verify_contract`, the regression `jq` gate, and the integration fixture: all move to `longcat-2.5-preview-free` / `opencode-go` together, and `remediation/worker-prompt.md` contains no model- or provider-specific text that would now be stale (grep for qwen/ollama/model/opencode in that file returns no matches). The only substantive new behaviour is the credential bridge in `model.py` (lines 595-612), which copies a hard-coded subset of the runner's `~/.local/share/opencode/auth.json` into the sandbox home so the previously credential-free worker can authenticate to OpenCode Go. That path is fail-open (`except Exception: pass`, plus a silent skip when the filtered dict is empty), admits one key beyond the policy's `providerId`, is not covered by the hermetic fixtures, and is not described in the boundary paragraph of `docs/auto-update-remediation.md`. I could not run `nix flake check`, the regression suites, or inspect the live Nova runner, so provisioning of the runner credential is raised as a question rather than asserted. ### Blocking findings None. ### Important findings - **Credential bridge is fail-open: a missing, unparseable, or unwritable provider credential is indistinguishable from a model failure** (scripts/nixos_update_remediation/model.py:611; high confidence) The new block (model.py:595-612) wraps the read, `json.load`, and `atomic_write_json` in `try: ... except Exception: pass`, and additionally writes nothing when the filtered dict is empty (`if sandbox_auth:` at line 607). `atomic_write_json` (core.py:181) raises `ControllerError`, which that bare handler also swallows. Unlike the previous loopback Ollama worker, `opencode-go` is an authenticated provider (`secrets/README.md:232` documents `opencode-go-api-key` being merged into `auth.json` as the `opencode-go` provider entry), so an absent key now yields an unauthenticated call whose only downstream signal is the generic post-run error. Every other boundary check in this controller is fail-closed with a specific reason string. Impact: An authentication/configuration regression is reported as an ambiguous model failure in the published diagnosis and incident state, so the fleet cannot separate a credential fault from a genuine model failure, and the fail-closed contract loses its specific cause. Suggested fix: Make the credential path fail closed: raise a `ControllerError` naming the cause (missing `opencode-go` key in the runner's `auth.json`, unparseable file, or failed sandbox write) instead of swallowing the exception, and treat an empty filtered credential set for the authenticated `policy["model"]["providerId"]` as an explicit error rather than a silent no-op. ### Suggestions - **Credential filter is hard-coded to `["opencode", "opencode-go"]` instead of the policy's providerId** (scripts/nixos_update_remediation/model.py:604; medium confidence) The filter admits every key in the literal list `["opencode", "opencode-go"]`, while `remediation/nova-policy.json` selects only `providerId: "opencode-go"`. `modules/profiles/ai-runtime.nix:348-354` shows the activation writing `openrouter`, `opencode-go`, and `pangolin-lyra` entries into `auth.json` (correctly excluded), so the extra admitted key `opencode` is not produced by that activation and is not the provider the policy selects. The copy is written into the writable bind-mounted sandbox home (`--bind str(home) /home/remediation`, with `--share-net` enabled), and the published model text fields pass only through `sanitise_plain_text` (core.py:187), which strips control characters and collapses whitespace but does not redact credential-like values. Impact: More auth/subscription material than the selected provider needs is reachable from a model-capable, network-enabled sandbox, and nothing in the controller would redact a credential echoed into the published diagnosis or rationale. Suggested fix: Filter to `policy["model"]["providerId"]` only (or state in the policy/docs why the `opencode` account entry is additionally required for an `opencode-go` request), so the admitted credential set is derived from the reviewed policy rather than a literal list. - **New credential bridge has no fixture coverage and reads the host's real credentials during the documented hermetic test run** (tests/nixos-update-remediation-integration.py:785; medium confidence) `assert_clean_model_boundary` asserts only on recorded `env` keys and the generated OpenCode config; nothing asserts that `auth.json` exists at `<sandbox home>/.local/share/opencode/auth.json`, that it is filtered, or that unrelated keys are excluded. The fixture invokes the controller with `controller_env = os.environ.copy()` (test line 1033), so `Path.home()` in model.py:597 resolves to the machine running the test, while `docs/auto-update-remediation.md:175` states these integration tests are hermetic and use fake OpenCode/Bubblewrap/Nix/Tea. Impact: A regression in the credential bridge (wrong key filter, no file written, wrong sandbox path) would pass the current suite, and the fixture's behaviour currently varies with the host it is run on. Suggested fix: Have the fixture supply a synthetic `auth.json` under a fixture-controlled `HOME` containing decoy keys (`openrouter`, `pangolin-lyra`) plus the permitted provider key, and assert the sandbox copy exists and contains only the permitted key. - **Reviewed boundary paragraph in the docs does not state that a provider credential is now admitted to the sandbox** (docs/auto-update-remediation.md:46; medium confidence) The edited sentence still enumerates only what the subprocess does *not* receive ("no Attic/ntfy/deployment secrets, Forgejo or checkout credentials, normal OpenCode config, MCP servers, ..."), and the only related edit deletes the word `auth` from "normal OpenCode auth/config". Nothing in the paragraph states that model.py:595-612 now copies the runner's filtered `opencode`/`opencode-go` credential into the sandbox home, which is the one credential material the model-capable job now holds. Impact: This paragraph is the reviewed contract for the worker boundary, so a reader would conclude no credential reaches the sandbox and mis-assess the isolation guarantee and the credential's publication risk. Suggested fix: State the credential bridge explicitly in this paragraph: which keys are copied, from which host path, and that the copy is confined to the sandbox home and never published. ### Tests and validation - No configured deterministic checks. ### Questions - Where is the Nova runner's `~/.local/share/opencode/auth.json` provisioned? `docs/nova-remote-builder.md` describes Nova as a Fedora host not registered in the flake, and the `opencode-go` entry is normally written by the home-manager activation in `modules/profiles/ai-runtime.nix:348-354`; `potential/nova/default.nix` contains no `ai-runtime` or opencode profile. Please confirm the `remediate` job's `HOME` actually contains an `opencode-go` key, since the code silently proceeds without it. - Should the generated provider definition keep forwarding `"npm": "@ai-sdk/openai-compatible"` from `remediation/nova-policy.json` while omitting `options.baseURL` (the policy no longer carries `baseUrl`, and `opencode_config` now emits that key only conditionally)? OpenCode's provider/auth registry is not in this checkout, so I cannot confirm that an `opencode-go` entry without a `baseURL` resolves to the correct endpoint and auth flow. - Is the `opencode` auth entry required for an `opencode-go` request, or is the `opencode-go` key alone sufficient? The filter admits both. - `contextTokens` is now 1000000 while `limits.modelEventBytes` (8 MiB), `limits.incidentBytes` (64 KiB), and the evidence bounds are unchanged. Is the larger context intended only to permit larger incident evidence, or should those bounds be raised to use it? ### Review limitations - I did not run `nix flake check`, `tests/nixos-update-remediation-regressions.sh`, `tests/nixos-update-remediation-integration.py`, or any repository code; the review container has no Nix, and the PR's claims that the suites pass and that live Bubblewrap execution returned `PONG` are unverified PR text. - The live Nova runner state is not supplied: I cannot confirm that `Path.home()` resolves to a home containing an `opencode-go` entry, nor the file's ownership/mode as seen by the sandbox uid 65534. - OpenCode's provider/auth registry and its `opencode-go`/`opencode` provider definitions are not in this checkout, so I cannot verify the generated `provider`/`models` config resolves to a working authenticated endpoint for `longcat-2.5-preview-free`. - `scripts/nova-remediation-benchmark.py`, `benchmarks/nova-remediation/`, and `tests/nova-remediation-benchmark.sh` are referenced by `.forgejo/workflows/attic-cache.yml` path filters but are absent from this checkout, so I could not assess whether they still assume the previous local model. - Only the supplied diff files and their surrounding code were inspected; unchanged code outside `scripts/nixos_update_remediation/`, its tests, and the remediation docs was not assessed for defects, and no finding outside the changed files is reported. ### Diff coverage - `docs/auto-update-remediation.md`: **reviewed** — included in a context-limited batch - `remediation/nova-policy.json`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/cli.py`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/core.py`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/model.py`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/publication.py`: **reviewed** — included in a context-limited batch - `tests/nixos-update-remediation-integration.py`: **reviewed** — included in a context-limited batch - `tests/nixos-update-remediation-regressions.sh`: **reviewed** — included in a context-limited batch <details><summary>Review metadata</summary> - Reviewer: forgejo-ai-review v1 - Model: strata/strata - Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/hermes-fleet-ssh.md, docs/nova-remote-builder.md, README.md - Commits considered: 1 - Previous automated review: none found - Findings: 4 </details>
fix(remediation): fail closed on missing auth and verify sandbox credentials
All checks were successful
Build and Push Attic Cache / test (pull_request) Successful in 1m25s
Build and Push Attic Cache / build (pull_request) Has been skipped
Build and Push Attic Cache / pin-lifecycle (pull_request) Has been skipped
Build and Push Attic Cache / remediate (pull_request) Has been skipped
Build and Push Attic Cache / notify-remediation (pull_request) Has been skipped
Build and Push Attic Cache / record-remediation-notify-failure (pull_request) Has been skipped
AI pull-request review / review (pull_request) Successful in 17m4s
af5504535e
Refs #328.
- Make model runner fail-closed if auth.json is missing or lacks opencode-go key
- Scope credentials copied into the sandbox strictly to the configured provider
- Document auth extraction behavior in docs/auto-update-remediation.md
- Add integration test assertions for sandbox auth isolation
clankbot left a comment

Automated code review

Reviewed commit: af5504535ec54672f7c231a795371d7c933aa552

Verdict: Requires further work

Resolve the blocking or important findings and investigate failed deterministic checks before merging.

Overall assessment

The supplied change repoints the remediation worker from the loopback Ollama Qwen model to the OpenCode Go longcat-2.5-preview-free provider and keeps the policy/controller/test assertions consistent: remediation/nova-policy.json (id + providerId, baseUrl removed), core.py:load_policy (id + providerId check), cli.py:verify_contract (model id), the jq fixture in tests/nixos-update-remediation-regressions.sh, and the integration fixture's model/provider assertions all agree, and no stale qwen3.6:35b-a3b-q8_0 or ollama-nova-remediation reference remains in the controller or its tests. The new credential plumbing in model.py reads only the configured provider key out of the runner's ~/.local/share/opencode/auth.json and writes it at share_home/opencode/auth.json, which matches the sandbox's HOME/XDG_DATA_HOME in model_environment(), at mode 0600 via atomic_write_json (default mode=0o600 in core.py:atomic_write_bytes), and the integration fixture proves the decoy keys are excluded. Two issues are worth attention: the credential reader validates file existence, JSON parseability and key presence, but not that the parsed document is an object, so a non-object auth.json raises a TypeError that escapes the controller's ControllerError contract and aborts the whole scan; and the policy still carries the Ollama-specific npm value while the baseUrl that accompanied it was deleted, so the generated provider block for the built-in opencode-go declares an OpenAI-compatible client with no endpoint, a pattern that appears nowhere else in the repository. No blocking defect was demonstrable from the supplied evidence.

Blocking findings

None.

Important findings

  • Non-object runner auth.json escapes ControllerError and aborts the whole scan batch (scripts/nixos_update_remediation/model.py:612; medium confidence)
    The new credential block checks only host_auth_file.is_file(), that json.load succeeds, and if provider_id not in host_auth: before doing atomic_write_json(data_opencode / "auth.json", {provider_id: host_auth[provider_id]}). Nothing asserts host_auth is a dict. A parseable non-object document satisfies in (a top-level string containing opencode-go, or an array containing it) and then host_auth[provider_id] raises TypeError: string indices must be integers / list indices must be integers; for a number, the in test itself raises TypeError: argument of type 'int' is not iterable. cli.py catches only ControllerError around run_model (except ControllerError as exc: result = fallback_result(...), cli.py:154) and only (ControllerError, BlockingIOError) per incident in the scan loop (cli.py:442), and entrypoint catches only TerminationRequested/ControllerError (cli.py:459-466), so a TypeError unwinds all three. The repository already ships a stricter reader, core.py:read_json, which raises ControllerError on OSError/UnicodeDecodeError/json.JSONDecodeError and rejects duplicate keys via object_pairs_hook=reject_duplicate_keys; the new code hand-rolls a weaker copy of it.
    Impact: One malformed credential file on the runner turns the documented fail-closed per-incident outcome (a diagnosis-only result with an audit reason, remaining incidents still processed) into an unhandled crash: the scan loop stops, atomic_write_json(Path(args.report_file)...) is never reached, the workflow's [ -s "$report_file" ] guard substitutes {"schemaVersion":1,"incidents":[]} so no follow-up URLs are emitted, and the incident state stays at advisory-attempt-started.
    Suggested fix: Validate the parsed credential document as a JSON object before indexing it and raise ControllerError otherwise (e.g. if not isinstance(host_auth, dict): raise ControllerError(f"runner credentials file at {host_auth_file} is not a JSON object")), or reuse the existing from .core import read_json helper already imported by model.py so the failure follows the bounded-diagnosis path instead of escaping the controller's error contract.

Suggestions

  • Policy keeps the Ollama-specific npm while its baseUrl was removed, generating a provider override with no endpoint (scripts/nixos_update_remediation/model.py:255; medium confidence)
    opencode_config now emits **({"npm": model["npm"]} if "npm" in model else {}) and **({"options": {"baseURL": model["baseUrl"]}} if "baseUrl" in model else {}). remediation/nova-policy.json deletes "baseUrl": "http://127.0.0.1:11434/v1" but keeps "npm": "@ai-sdk/openai-compatible", so the generated config declares provider.opencode-go with an OpenAI-compatible client and no options.baseURL. Every other explicit provider definition in the repository pairs the two keys (modules/profiles/ai-runtime.nix:189 and hosts/electra/default.nix:90 set npm together with options.baseURL), whereas opencode-go is otherwise used only as a built-in provider with no provider block at all: modules/profiles/ai-runtime.nix:153 lists it in enabled_providers and its credential is merged at ai-runtime.nix:352; the only explicit OpenCode Go endpoint in the repo is Hermes' base_url = "https://opencode.ai/zen/go/v1" (modules/services/hermes.nix:233).
    Impact: If OpenCode treats a provider entry as a definition rather than an overlay on the built-in opencode-go, the worker would have no resolvable endpoint and every advisory attempt would fail at the model call, which the controller reports as a diagnosis-only failure rather than a policy error - a silent loss of remediation coverage rather than a loud configuration error.
    Suggested fix: Confirm the generated config against a live run, and either drop npm from remediation/nova-policy.json for opencode-go so the built-in provider definition is inherited, or state the OpenCode Go base URL explicitly in the policy; the conditional injection in opencode_config already supports omitting either key.

Tests and validation

  • No configured deterministic checks.

Questions

  • Does the live Nova runner actually have ~/.local/share/opencode/auth.json with an opencode-go entry? potential/nova/default.nix imports modules/profiles/ai-agents.nix (which contains no opencode reference) and modules/profiles/ollama.nix, not modules/profiles/ai-runtime.nix, which is the only place in the flake that merges an opencode-go credential into that file; the workflow's bootstrap step only tests test -x /home/nimmo/.opencode/bin/opencode (attic-cache.yml:315), so the new fail-closed check would surface only mid-scan.
  • Should remediation/worker-prompt.md be updated? Its trust-boundary text (line 12) still says "user homes, credentials, environment variables ... are deliberately unavailable", which is no longer literally true once the provider credential is mounted at /home/remediation/.local/share/opencode/auth.json; verify_contract asserts only four other boundary strings, so nothing would catch the drift.
  • Is the credential lookup intended to follow XDG_DATA_HOME rather than a hardcoded .local/share/opencode under Path.home()? The workflow overrides XDG_CONFIG_HOME for the scan (attic-cache.yml:345) but not XDG_DATA_HOME, so the current hardcoded path matches the runner today.

Review limitations

  • No access to the OpenCode runtime, the Nova runner, or the runner's auth.json; provider-definition overlay semantics and credential provisioning could not be verified.
  • Repository code was not executed and nix flake check, the regression script, and the integration test were not run; the PR's validation claims are treated as untrusted evidence.
  • Only the supplied diff and the checked-out files were available; no CI logs, incident bundles, or published issues/PRs were supplied, so runtime behaviour of the new credential path is unverified.
  • No deterministic checks were configured for this review, so no factual gate results were available to corroborate the change.

Diff coverage

  • docs/auto-update-remediation.md: reviewed — included in a context-limited batch
  • remediation/nova-policy.json: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/cli.py: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/core.py: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/model.py: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/publication.py: reviewed — included in a context-limited batch
  • tests/nixos-update-remediation-integration.py: reviewed — included in a context-limited batch
  • tests/nixos-update-remediation-regressions.sh: reviewed — included in a context-limited batch
Review metadata
  • Reviewer: forgejo-ai-review v1
  • Model: strata/strata
  • Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/hermes-fleet-ssh.md, docs/nova-remote-builder.md, README.md
  • Commits considered: 2
  • Previous automated review: none found
  • Findings: 2
<!-- forgejo-ai-review:v1 --> ## Automated code review Reviewed commit: `af5504535ec54672f7c231a795371d7c933aa552` ## Verdict: Requires further work Resolve the blocking or important findings and investigate failed deterministic checks before merging. ### Overall assessment The supplied change repoints the remediation worker from the loopback Ollama Qwen model to the OpenCode Go `longcat-2.5-preview-free` provider and keeps the policy/controller/test assertions consistent: `remediation/nova-policy.json` (id + providerId, baseUrl removed), `core.py:load_policy` (id + providerId check), `cli.py:verify_contract` (model id), the jq fixture in `tests/nixos-update-remediation-regressions.sh`, and the integration fixture's model/provider assertions all agree, and no stale `qwen3.6:35b-a3b-q8_0` or `ollama-nova-remediation` reference remains in the controller or its tests. The new credential plumbing in `model.py` reads only the configured provider key out of the runner's `~/.local/share/opencode/auth.json` and writes it at `share_home/opencode/auth.json`, which matches the sandbox's `HOME`/`XDG_DATA_HOME` in `model_environment()`, at mode 0600 via `atomic_write_json` (default `mode=0o600` in `core.py:atomic_write_bytes`), and the integration fixture proves the decoy keys are excluded. Two issues are worth attention: the credential reader validates file existence, JSON parseability and key presence, but not that the parsed document is an object, so a non-object `auth.json` raises a `TypeError` that escapes the controller's `ControllerError` contract and aborts the whole scan; and the policy still carries the Ollama-specific `npm` value while the `baseUrl` that accompanied it was deleted, so the generated provider block for the built-in `opencode-go` declares an OpenAI-compatible client with no endpoint, a pattern that appears nowhere else in the repository. No blocking defect was demonstrable from the supplied evidence. ### Blocking findings None. ### Important findings - **Non-object runner auth.json escapes ControllerError and aborts the whole scan batch** (scripts/nixos_update_remediation/model.py:612; medium confidence) The new credential block checks only `host_auth_file.is_file()`, that `json.load` succeeds, and `if provider_id not in host_auth:` before doing `atomic_write_json(data_opencode / "auth.json", {provider_id: host_auth[provider_id]})`. Nothing asserts `host_auth` is a dict. A parseable non-object document satisfies `in` (a top-level string containing `opencode-go`, or an array containing it) and then `host_auth[provider_id]` raises `TypeError: string indices must be integers` / `list indices must be integers`; for a number, the `in` test itself raises `TypeError: argument of type 'int' is not iterable`. `cli.py` catches only `ControllerError` around `run_model` (`except ControllerError as exc: result = fallback_result(...)`, cli.py:154) and only `(ControllerError, BlockingIOError)` per incident in the scan loop (cli.py:442), and `entrypoint` catches only `TerminationRequested`/`ControllerError` (cli.py:459-466), so a `TypeError` unwinds all three. The repository already ships a stricter reader, `core.py:read_json`, which raises `ControllerError` on `OSError/UnicodeDecodeError/json.JSONDecodeError` and rejects duplicate keys via `object_pairs_hook=reject_duplicate_keys`; the new code hand-rolls a weaker copy of it. Impact: One malformed credential file on the runner turns the documented fail-closed per-incident outcome (a diagnosis-only result with an audit reason, remaining incidents still processed) into an unhandled crash: the scan loop stops, `atomic_write_json(Path(args.report_file)...)` is never reached, the workflow's `[ -s "$report_file" ]` guard substitutes `{"schemaVersion":1,"incidents":[]}` so no follow-up URLs are emitted, and the incident state stays at `advisory-attempt-started`. Suggested fix: Validate the parsed credential document as a JSON object before indexing it and raise `ControllerError` otherwise (e.g. `if not isinstance(host_auth, dict): raise ControllerError(f"runner credentials file at {host_auth_file} is not a JSON object")`), or reuse the existing `from .core import read_json` helper already imported by `model.py` so the failure follows the bounded-diagnosis path instead of escaping the controller's error contract. ### Suggestions - **Policy keeps the Ollama-specific `npm` while its `baseUrl` was removed, generating a provider override with no endpoint** (scripts/nixos_update_remediation/model.py:255; medium confidence) `opencode_config` now emits `**({"npm": model["npm"]} if "npm" in model else {})` and `**({"options": {"baseURL": model["baseUrl"]}} if "baseUrl" in model else {})`. `remediation/nova-policy.json` deletes `"baseUrl": "http://127.0.0.1:11434/v1"` but keeps `"npm": "@ai-sdk/openai-compatible"`, so the generated config declares `provider.opencode-go` with an OpenAI-compatible client and no `options.baseURL`. Every other explicit provider definition in the repository pairs the two keys (`modules/profiles/ai-runtime.nix:189` and `hosts/electra/default.nix:90` set `npm` together with `options.baseURL`), whereas `opencode-go` is otherwise used only as a built-in provider with no `provider` block at all: `modules/profiles/ai-runtime.nix:153` lists it in `enabled_providers` and its credential is merged at `ai-runtime.nix:352`; the only explicit OpenCode Go endpoint in the repo is Hermes' `base_url = "https://opencode.ai/zen/go/v1"` (`modules/services/hermes.nix:233`). Impact: If OpenCode treats a `provider` entry as a definition rather than an overlay on the built-in `opencode-go`, the worker would have no resolvable endpoint and every advisory attempt would fail at the model call, which the controller reports as a diagnosis-only failure rather than a policy error - a silent loss of remediation coverage rather than a loud configuration error. Suggested fix: Confirm the generated config against a live run, and either drop `npm` from `remediation/nova-policy.json` for `opencode-go` so the built-in provider definition is inherited, or state the OpenCode Go base URL explicitly in the policy; the conditional injection in `opencode_config` already supports omitting either key. ### Tests and validation - No configured deterministic checks. ### Questions - Does the live Nova runner actually have `~/.local/share/opencode/auth.json` with an `opencode-go` entry? `potential/nova/default.nix` imports `modules/profiles/ai-agents.nix` (which contains no `opencode` reference) and `modules/profiles/ollama.nix`, not `modules/profiles/ai-runtime.nix`, which is the only place in the flake that merges an `opencode-go` credential into that file; the workflow's bootstrap step only tests `test -x /home/nimmo/.opencode/bin/opencode` (attic-cache.yml:315), so the new fail-closed check would surface only mid-scan. - Should `remediation/worker-prompt.md` be updated? Its trust-boundary text (line 12) still says "user homes, credentials, environment variables ... are deliberately unavailable", which is no longer literally true once the provider credential is mounted at `/home/remediation/.local/share/opencode/auth.json`; `verify_contract` asserts only four other boundary strings, so nothing would catch the drift. - Is the credential lookup intended to follow `XDG_DATA_HOME` rather than a hardcoded `.local/share/opencode` under `Path.home()`? The workflow overrides `XDG_CONFIG_HOME` for the scan (attic-cache.yml:345) but not `XDG_DATA_HOME`, so the current hardcoded path matches the runner today. ### Review limitations - No access to the OpenCode runtime, the Nova runner, or the runner's `auth.json`; provider-definition overlay semantics and credential provisioning could not be verified. - Repository code was not executed and `nix flake check`, the regression script, and the integration test were not run; the PR's validation claims are treated as untrusted evidence. - Only the supplied diff and the checked-out files were available; no CI logs, incident bundles, or published issues/PRs were supplied, so runtime behaviour of the new credential path is unverified. - No deterministic checks were configured for this review, so no factual gate results were available to corroborate the change. ### Diff coverage - `docs/auto-update-remediation.md`: **reviewed** — included in a context-limited batch - `remediation/nova-policy.json`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/cli.py`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/core.py`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/model.py`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/publication.py`: **reviewed** — included in a context-limited batch - `tests/nixos-update-remediation-integration.py`: **reviewed** — included in a context-limited batch - `tests/nixos-update-remediation-regressions.sh`: **reviewed** — included in a context-limited batch <details><summary>Review metadata</summary> - Reviewer: forgejo-ai-review v1 - Model: strata/strata - Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/hermes-fleet-ssh.md, docs/nova-remote-builder.md, README.md - Commits considered: 2 - Previous automated review: none found - Findings: 2 </details>
fix(remediation): use read_json for runner auth, validate dict type, and drop unused npm override
All checks were successful
Build and Push Attic Cache / test (pull_request) Successful in 1m29s
Build and Push Attic Cache / build (pull_request) Has been skipped
Build and Push Attic Cache / pin-lifecycle (pull_request) Has been skipped
Build and Push Attic Cache / remediate (pull_request) Has been skipped
Build and Push Attic Cache / notify-remediation (pull_request) Has been skipped
Build and Push Attic Cache / record-remediation-notify-failure (pull_request) Has been skipped
AI pull-request review / review (pull_request) Successful in 16m9s
d5a02a8be0
Refs #328.
- Use read_json to parse runner auth.json with strict error handling and duplicate key rejection
- Verify host_auth is a JSON object and raise ControllerError otherwise to prevent unhandled TypeErrors
- Drop unused npm field in policy so OpenCode inherits its native opencode-go built-in provider definition
- Clarify host user homes and deployment credentials in worker-prompt.md trust boundary
- Add hermetic test coverage asserting ControllerError on non-object auth.json payloads
Author
Owner

Automated Review Response (Commit d5a02a8)

Thank you for the review feedback on commit af55045. All actionable findings have been resolved in d5a02a8:

  1. Non-object runner auth.json validation (Important finding):

    • Replaced hand-rolled JSON parsing in scripts/nixos_update_remediation/model.py with the repository's strict read_json helper from core.py (which rejects duplicate keys and handles decoding errors).
    • Added an explicit isinstance(host_auth, dict) guard that raises ControllerError(f"runner credentials file at {host_auth_file} is not a JSON object") to ensure non-dict payloads fail closed cleanly instead of raising unhandled TypeErrors during scan loops.
    • Added hermetic integration test assertions in tests/nixos-update-remediation-integration.py exercising run_model with string, array, and int payloads, proving they all fail closed cleanly with ControllerError.
  2. Policy provider definition (Suggestion):

    • Removed "npm": "@ai-sdk/openai-compatible" from remediation/nova-policy.json.
    • OpenCode includes native built-in provider support for opencode-go. Dropping the unused NPM override allows OpenCode to inherit its native provider definition directly without constructing an endpoint-less OpenAI-compatible overlay.
  3. Worker prompt boundary clarification (Question):

    • Updated remediation/worker-prompt.md trust-boundary text to clarify that host user homes, Attic/deployment credentials, and unrelated secrets are deliberately unavailable.
  4. Nova Runner Provisioning (Question):

    • Confirmed that ~/.local/share/opencode/auth.json (mode 0600) is provisioned on the Nova runner and verified against the live Bubblewrap container with model opencode-go/longcat-2.5-preview-free (PONG verified).
### Automated Review Response (Commit `d5a02a8`) Thank you for the review feedback on commit `af55045`. All actionable findings have been resolved in `d5a02a8`: 1. **Non-object runner auth.json validation (Important finding)**: - Replaced hand-rolled JSON parsing in `scripts/nixos_update_remediation/model.py` with the repository's strict `read_json` helper from `core.py` (which rejects duplicate keys and handles decoding errors). - Added an explicit `isinstance(host_auth, dict)` guard that raises `ControllerError(f"runner credentials file at {host_auth_file} is not a JSON object")` to ensure non-dict payloads fail closed cleanly instead of raising unhandled `TypeError`s during scan loops. - Added hermetic integration test assertions in `tests/nixos-update-remediation-integration.py` exercising `run_model` with string, array, and int payloads, proving they all fail closed cleanly with `ControllerError`. 2. **Policy provider definition (Suggestion)**: - Removed `"npm": "@ai-sdk/openai-compatible"` from `remediation/nova-policy.json`. - OpenCode includes native built-in provider support for `opencode-go`. Dropping the unused NPM override allows OpenCode to inherit its native provider definition directly without constructing an endpoint-less OpenAI-compatible overlay. 3. **Worker prompt boundary clarification (Question)**: - Updated `remediation/worker-prompt.md` trust-boundary text to clarify that host user homes, Attic/deployment credentials, and unrelated secrets are deliberately unavailable. 4. **Nova Runner Provisioning (Question)**: - Confirmed that `~/.local/share/opencode/auth.json` (mode 0600) is provisioned on the Nova runner and verified against the live Bubblewrap container with model `opencode-go/longcat-2.5-preview-free` (`PONG` verified).
clankbot left a comment

Automated code review

Reviewed commit: d5a02a8be05024302e6f7895364da59c1f1581ed

Verdict: Requires further work

Resolve the blocking or important findings and investigate failed deterministic checks before merging.

Overall assessment

The provider switch is internally consistent across remediation/nova-policy.json, core.load_policy, cli.verify_contract, the jq regression gate, the integration fixtures, and docs/auto-update-remediation.md (all pin longcat-2.5-preview-free / opencode-go), and the new credential path in model.py is fail-closed and copies only the reviewed provider key. The material concern is placement: the credential check runs inside run_model, after cli.py has already recorded attemptCount: 1, so a runner-credential fault is indistinguishable from a model failure and permanently marks the incident diagnosis-only. Two secondary, evidence-backed concerns are the unbounded/unvalidated read of the host auth.json (every other controller read passes an explicit byte bound) and the worker trust-boundary text, which now enumerates only 'host user homes' and 'Attic/deployment credentials' while the change places an OpenCode Go credential inside the sandbox home the worker can read.

Blocking findings

None.

Important findings

  • Missing or malformed runner credential permanently consumes the incident's single model attempt (scripts/nixos_update_remediation/model.py:595; high confidence)
    cli.py:126 writes {"attemptCount": 1, "status": "advisory-attempt-started"} and state_writes it before run_model is called, and cli.py:101 returns early for any incident with attemptCount >= 1. The new block at model.py:595-627 raises ControllerError for a missing file, unparsable JSON, non-object, or absent opencode-go key; cli.py:154 catches that ControllerError and substitutes fallback_result (core.py:819-828, disposition "diagnosis-only", rationale = the ControllerError text), which cli.py then publishes and persists as status "published-diagnosis". docs/auto-update-remediation.md (unchanged context in the diff) states previously handled fingerprints 'never receive a second model attempt'. The workflow pre-flight (.forgejo/workflows/attic-cache.yml:315-316) only runs test -x /home/nimmo/.opencode/bin/opencode and ./scripts/nixos-update-remediation.py verify, and cli.verify_contract (cli.py:305-322) inspects only the prompt text and policy model id, so no supplied step checks auth.json before the scan starts.
    Impact: A runner-configuration fault (credential file absent, renamed, unreadable, or lacking the opencode-go key) is indistinguishable from a genuine model failure: every incident in that scan run is published as a diagnosis-only issue whose rationale is the credential error, is marked handled, and never receives a real model diagnosis after the credential is fixed. The failure is also not detected before the scan begins, so it consumes the per-incident attempt budget and generates published issues plus follow-ups for a configuration problem.
    Suggested fix: Validate the provider credential before the attempt is consumed: perform the auth.json presence/shape check in cli.verify_contract / the verify subcommand (or at intake, before attemptCount is written) and treat a credential fault as a job-level failure that leaves the incident unattempted, rather than raising ControllerError from inside run_model after the attempt has been recorded.

Suggestions

  • Host auth.json is read and copied without any byte bound or value validation (scripts/nixos_update_remediation/model.py:605; medium confidence)
    host_auth = read_json(host_auth_file) is called with no maximum, while core.read_json (core.py:149-160) only enforces a limit when one is supplied; every other controller read in the supplied code passes an explicit bound (e.g. read_json(path, 64 * 1024) for model results, 128 * 1024 for the policy, 256 * 1024 for the validation record). The unchecked value is then written verbatim with atomic_write_json (core.py:181-184, which also passes no maximum) into the sandbox home at model.py:623-627, and the resulting ControllerError text at model.py:606-611 interpolates the exception and the host path, which cli.py:154 -> fallback_result (core.py:827, rationale = sanitise_plain_text(reason)) places into the published issue body.
    Impact: A large or pathological host credentials file is loaded and re-serialized in full, and an arbitrarily large or unexpectedly shaped provider entry is written into the sandbox home, outside the bounded-evidence discipline the controller otherwise applies; the host absolute path also appears in a public issue body.
    Suggested fix: Pass an explicit size bound (e.g. read_json(host_auth_file, 64 * 1024)), validate the copied provider entry's shape and size before writing it, and raise a fixed message rather than interpolating the underlying exception text and host path into a published note.

  • Worker trust-boundary text no longer describes the credential the change places in the sandbox (remediation/worker-prompt.md:11; medium confidence)
    The changed boundary line now reads 'host user homes, Attic/deployment credentials, environment variables ... are deliberately unavailable', but model.py:623-627 writes {provider_id: host_auth[provider_id]} to the sandbox path /home/remediation/.local/share/opencode/auth.json, which is bind-mounted read-write into the sandbox (model.py '--bind str(home) /home/remediation') and is readable by the worker (opencode_config permission read: {'*': 'allow'}, model.py:197-201). model_environment() also sets XDG_DATA_HOME=/home/remediation/.local/share, so the file is the worker's own provider credential. docs/auto-update-remediation.md documents this copy, so the prompt and the code disagree about what the worker can see.
    Impact: The reviewed worker contract no longer enumerates the one credential that is present in the worker environment, and cli.verify_contract only checks four other boundary strings (cli.py:305-311), so nothing pins the corrected wording. A future relaxation of the bash/external_directory denies could place a subscription API key into worker-visible output with no controller-side guard.
    Suggested fix: State the exception explicitly in the boundary text (only the opencode-go provider credential is present and must never be quoted or echoed), and consider a controller check that the published diagnosis/rationale do not contain the credential value.

Tests and validation

  • No configured deterministic checks.

Questions

  • Does the runner's ~/.local/share/opencode/auth.json (resolved from the workflow's $HOME) actually contain an opencode-go entry in the CI environment? Nothing in the supplied repository material provisions or pre-flights that credential; the workflow step only tests the OpenCode binary.
  • Does OpenCode accept the generated provider.opencode-go definition with neither npm nor options.baseURL? model.py:255-256 emits those keys only when present in the policy, and remediation/nova-policy.json no longer carries them; no supplied evidence pins OpenCode's provider schema or the built-in opencode-go definition.
  • Is consuming the user's OpenCode Go subscription from an unattended CI scan an accepted fleet policy, and is the shared network now reaching a cloud endpoint (model.py audit field 'shared for model provider') an accepted change to the isolation boundary previously described as loopback-only?

Review limitations

  • I did not execute repository code, edit files, or run the test suites; no Nix toolchain was used, so the PR's claims (live Bubblewrap PONG run, passing integration and regression suites) remain unverified.
  • The only supplied evidence for the auth.json format is the test fixture's synthetic {"type": "api", "key": "fake-go-key"} entry (tests/nixos-update-remediation-integration.py); there is no schema or fixture for the real OpenCode auth.json or the opencode-go provider definition, so runtime acceptance of the generated configuration cannot be confirmed.
  • I inspected unchanged files only to trace callers and publication paths (cli.py attempt bookkeeping, core.py read_json/atomic_write_json/fallback_result, publication.py issue_body, the attic-cache workflow pre-flight) and did not audit files outside the changed set further than that.

Diff coverage

  • docs/auto-update-remediation.md: reviewed — included in a context-limited batch
  • remediation/nova-policy.json: reviewed — included in a context-limited batch
  • remediation/worker-prompt.md: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/cli.py: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/core.py: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/model.py: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/publication.py: reviewed — included in a context-limited batch
  • tests/nixos-update-remediation-integration.py: reviewed — included in a context-limited batch
  • tests/nixos-update-remediation-regressions.sh: reviewed — included in a context-limited batch
Review metadata
  • Reviewer: forgejo-ai-review v1
  • Model: strata/strata
  • Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/hermes-fleet-ssh.md, docs/nova-remote-builder.md, README.md
  • Commits considered: 3
  • Previous automated review: none found
  • Findings: 3
<!-- forgejo-ai-review:v1 --> ## Automated code review Reviewed commit: `d5a02a8be05024302e6f7895364da59c1f1581ed` ## Verdict: Requires further work Resolve the blocking or important findings and investigate failed deterministic checks before merging. ### Overall assessment The provider switch is internally consistent across remediation/nova-policy.json, core.load_policy, cli.verify_contract, the jq regression gate, the integration fixtures, and docs/auto-update-remediation.md (all pin longcat-2.5-preview-free / opencode-go), and the new credential path in model.py is fail-closed and copies only the reviewed provider key. The material concern is placement: the credential check runs inside run_model, after cli.py has already recorded attemptCount: 1, so a runner-credential fault is indistinguishable from a model failure and permanently marks the incident diagnosis-only. Two secondary, evidence-backed concerns are the unbounded/unvalidated read of the host auth.json (every other controller read passes an explicit byte bound) and the worker trust-boundary text, which now enumerates only 'host user homes' and 'Attic/deployment credentials' while the change places an OpenCode Go credential inside the sandbox home the worker can read. ### Blocking findings None. ### Important findings - **Missing or malformed runner credential permanently consumes the incident's single model attempt** (scripts/nixos_update_remediation/model.py:595; high confidence) cli.py:126 writes {"attemptCount": 1, "status": "advisory-attempt-started"} and state_writes it before run_model is called, and cli.py:101 returns early for any incident with attemptCount >= 1. The new block at model.py:595-627 raises ControllerError for a missing file, unparsable JSON, non-object, or absent opencode-go key; cli.py:154 catches that ControllerError and substitutes fallback_result (core.py:819-828, disposition "diagnosis-only", rationale = the ControllerError text), which cli.py then publishes and persists as status "published-diagnosis". docs/auto-update-remediation.md (unchanged context in the diff) states previously handled fingerprints 'never receive a second model attempt'. The workflow pre-flight (.forgejo/workflows/attic-cache.yml:315-316) only runs `test -x /home/nimmo/.opencode/bin/opencode` and `./scripts/nixos-update-remediation.py verify`, and cli.verify_contract (cli.py:305-322) inspects only the prompt text and policy model id, so no supplied step checks auth.json before the scan starts. Impact: A runner-configuration fault (credential file absent, renamed, unreadable, or lacking the opencode-go key) is indistinguishable from a genuine model failure: every incident in that scan run is published as a diagnosis-only issue whose rationale is the credential error, is marked handled, and never receives a real model diagnosis after the credential is fixed. The failure is also not detected before the scan begins, so it consumes the per-incident attempt budget and generates published issues plus follow-ups for a configuration problem. Suggested fix: Validate the provider credential before the attempt is consumed: perform the auth.json presence/shape check in cli.verify_contract / the verify subcommand (or at intake, before attemptCount is written) and treat a credential fault as a job-level failure that leaves the incident unattempted, rather than raising ControllerError from inside run_model after the attempt has been recorded. ### Suggestions - **Host auth.json is read and copied without any byte bound or value validation** (scripts/nixos_update_remediation/model.py:605; medium confidence) `host_auth = read_json(host_auth_file)` is called with no maximum, while core.read_json (core.py:149-160) only enforces a limit when one is supplied; every other controller read in the supplied code passes an explicit bound (e.g. read_json(path, 64 * 1024) for model results, 128 * 1024 for the policy, 256 * 1024 for the validation record). The unchecked value is then written verbatim with atomic_write_json (core.py:181-184, which also passes no maximum) into the sandbox home at model.py:623-627, and the resulting ControllerError text at model.py:606-611 interpolates the exception and the host path, which cli.py:154 -> fallback_result (core.py:827, rationale = sanitise_plain_text(reason)) places into the published issue body. Impact: A large or pathological host credentials file is loaded and re-serialized in full, and an arbitrarily large or unexpectedly shaped provider entry is written into the sandbox home, outside the bounded-evidence discipline the controller otherwise applies; the host absolute path also appears in a public issue body. Suggested fix: Pass an explicit size bound (e.g. read_json(host_auth_file, 64 * 1024)), validate the copied provider entry's shape and size before writing it, and raise a fixed message rather than interpolating the underlying exception text and host path into a published note. - **Worker trust-boundary text no longer describes the credential the change places in the sandbox** (remediation/worker-prompt.md:11; medium confidence) The changed boundary line now reads 'host user homes, Attic/deployment credentials, environment variables ... are deliberately unavailable', but model.py:623-627 writes {provider_id: host_auth[provider_id]} to the sandbox path /home/remediation/.local/share/opencode/auth.json, which is bind-mounted read-write into the sandbox (model.py '--bind str(home) /home/remediation') and is readable by the worker (opencode_config permission read: {'*': 'allow'}, model.py:197-201). model_environment() also sets XDG_DATA_HOME=/home/remediation/.local/share, so the file is the worker's own provider credential. docs/auto-update-remediation.md documents this copy, so the prompt and the code disagree about what the worker can see. Impact: The reviewed worker contract no longer enumerates the one credential that is present in the worker environment, and cli.verify_contract only checks four other boundary strings (cli.py:305-311), so nothing pins the corrected wording. A future relaxation of the bash/external_directory denies could place a subscription API key into worker-visible output with no controller-side guard. Suggested fix: State the exception explicitly in the boundary text (only the opencode-go provider credential is present and must never be quoted or echoed), and consider a controller check that the published diagnosis/rationale do not contain the credential value. ### Tests and validation - No configured deterministic checks. ### Questions - Does the runner's ~/.local/share/opencode/auth.json (resolved from the workflow's $HOME) actually contain an opencode-go entry in the CI environment? Nothing in the supplied repository material provisions or pre-flights that credential; the workflow step only tests the OpenCode binary. - Does OpenCode accept the generated provider.opencode-go definition with neither `npm` nor `options.baseURL`? model.py:255-256 emits those keys only when present in the policy, and remediation/nova-policy.json no longer carries them; no supplied evidence pins OpenCode's provider schema or the built-in opencode-go definition. - Is consuming the user's OpenCode Go subscription from an unattended CI scan an accepted fleet policy, and is the shared network now reaching a cloud endpoint (model.py audit field 'shared for model provider') an accepted change to the isolation boundary previously described as loopback-only? ### Review limitations - I did not execute repository code, edit files, or run the test suites; no Nix toolchain was used, so the PR's claims (live Bubblewrap PONG run, passing integration and regression suites) remain unverified. - The only supplied evidence for the auth.json format is the test fixture's synthetic {"type": "api", "key": "fake-go-key"} entry (tests/nixos-update-remediation-integration.py); there is no schema or fixture for the real OpenCode auth.json or the opencode-go provider definition, so runtime acceptance of the generated configuration cannot be confirmed. - I inspected unchanged files only to trace callers and publication paths (cli.py attempt bookkeeping, core.py read_json/atomic_write_json/fallback_result, publication.py issue_body, the attic-cache workflow pre-flight) and did not audit files outside the changed set further than that. ### Diff coverage - `docs/auto-update-remediation.md`: **reviewed** — included in a context-limited batch - `remediation/nova-policy.json`: **reviewed** — included in a context-limited batch - `remediation/worker-prompt.md`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/cli.py`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/core.py`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/model.py`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/publication.py`: **reviewed** — included in a context-limited batch - `tests/nixos-update-remediation-integration.py`: **reviewed** — included in a context-limited batch - `tests/nixos-update-remediation-regressions.sh`: **reviewed** — included in a context-limited batch <details><summary>Review metadata</summary> - Reviewer: forgejo-ai-review v1 - Model: strata/strata - Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/hermes-fleet-ssh.md, docs/nova-remote-builder.md, README.md - Commits considered: 3 - Previous automated review: none found - Findings: 3 </details>
fix(remediation): validate credentials before consuming incident attempt and guard against leaks
All checks were successful
Build and Push Attic Cache / test (pull_request) Successful in 1m25s
Build and Push Attic Cache / build (pull_request) Has been skipped
Build and Push Attic Cache / pin-lifecycle (pull_request) Has been skipped
Build and Push Attic Cache / remediate (pull_request) Has been skipped
Build and Push Attic Cache / notify-remediation (pull_request) Has been skipped
Build and Push Attic Cache / record-remediation-notify-failure (pull_request) Has been skipped
AI pull-request review / review (pull_request) Successful in 22m41s
ceaacddc0e
Refs #328.
- Extract get_runner_provider_credentials helper with 64 KiB read bound and object shape validation
- Validate runner credentials at intake and scan start so credential issues fail early without consuming incident attempt budget
- Guard validate_model_result against echoing runner credential material in model diagnosis or patch
- Explicitly state opencode-go provider credential exception and echo prohibition in worker prompt
- Add integration test asserting broken runner credentials leave incidents unattempted
Author
Owner

Automated Review Response (Commit ceaacdd)

Thank you for the detailed review on commit d5a02a8. All findings have been addressed in ceaacdd:

  1. Pre-attempt Credential Validation (Important finding):

    • Extracted helper get_runner_provider_credentials(policy) in scripts/nixos_update_remediation/model.py.
    • In process_incident (scripts/nixos_update_remediation/cli.py), runner credentials are now validated before state.update({"attemptCount": 1, ...}). If runner credentials are missing or corrupted, the controller raises ControllerError without consuming the incident attempt budget or persisting an erroneous diagnosis-only outcome.
    • In cmd_scan, runner credentials are also validated upfront whenever incidents are queued, failing the scan job before touching any incident.
    • Added an integration test in tests/nixos-update-remediation-integration.py proving that a broken runner auth file leaves remediation-state.json unattempted (attemptCount not incremented).
  2. Bounded Auth Read & Shape Validation (Suggestion):

    • get_runner_provider_credentials passes an explicit 64 * 1024 byte bound to read_json.
    • Validates that both host_auth and host_auth[provider_id] are valid JSON dicts.
    • Added integration test coverage for auth files exceeding 64 KiB, proving they fail closed.
  3. Trust Boundary Text & Credential Leak Guard (Suggestion):

    • Updated remediation/worker-prompt.md to explicitly state:

      Only your opencode-go provider credential is provisioned in your sandbox home for API communication; never quote, leak, or echo credential material into result.json or proposal.patch.

    • Added an active safety guard in validate_model_result (scripts/nixos_update_remediation/model.py) that checks result["diagnosis"], result["rationale"], and patch_path for the runner credential string and rejects the proposal if credential material is echoed.
### Automated Review Response (Commit `ceaacdd`) Thank you for the detailed review on commit `d5a02a8`. All findings have been addressed in `ceaacdd`: 1. **Pre-attempt Credential Validation (Important finding)**: - Extracted helper `get_runner_provider_credentials(policy)` in `scripts/nixos_update_remediation/model.py`. - In `process_incident` (`scripts/nixos_update_remediation/cli.py`), runner credentials are now validated **before** `state.update({"attemptCount": 1, ...})`. If runner credentials are missing or corrupted, the controller raises `ControllerError` without consuming the incident attempt budget or persisting an erroneous diagnosis-only outcome. - In `cmd_scan`, runner credentials are also validated upfront whenever incidents are queued, failing the scan job before touching any incident. - Added an integration test in `tests/nixos-update-remediation-integration.py` proving that a broken runner auth file leaves `remediation-state.json` unattempted (`attemptCount` not incremented). 2. **Bounded Auth Read & Shape Validation (Suggestion)**: - `get_runner_provider_credentials` passes an explicit `64 * 1024` byte bound to `read_json`. - Validates that both `host_auth` and `host_auth[provider_id]` are valid JSON dicts. - Added integration test coverage for auth files exceeding 64 KiB, proving they fail closed. 3. **Trust Boundary Text & Credential Leak Guard (Suggestion)**: - Updated `remediation/worker-prompt.md` to explicitly state: > Only your `opencode-go` provider credential is provisioned in your sandbox home for API communication; never quote, leak, or echo credential material into `result.json` or `proposal.patch`. - Added an active safety guard in `validate_model_result` (`scripts/nixos_update_remediation/model.py`) that checks `result["diagnosis"]`, `result["rationale"]`, and `patch_path` for the runner credential string and rejects the proposal if credential material is echoed.
clankbot left a comment

Automated code review

Reviewed commit: ceaacddc0e889d7ca6ecc20cd5afb945c7879fdb

Verdict: Ready to merge

No blocking or important findings were retained, and deterministic checks passed. Suggestions remain advisory.

Overall assessment

The model/provider switch is applied coherently across remediation/nova-policy.json, core.load_policy, cli.verify_contract, the regression jq gate, the docs, and the integration fixtures: every qwen3.6:35b-a3b-q8_0/ollama-nova-remediation reference is gone from the checked-out remediation subsystem (a repo-wide search for qwen3.6|ollama-nova-remediation|11434 matches only unrelated Hermes/electra/ollama-profile files, not the controller or its tests). The new credential plumbing reads Path.home()/.local/share/opencode/auth.json, keeps only the opencode-go entry, and writes it via atomic_write_json (mode 0600) into the sandbox home that model_environment() maps to HOME=/home/remediation, which matches the documented boundary and the fixture's expected sandboxAuth. The credential pre-checks in cli.process_incident and cli.main run before attemptCount is set, so the new 'unattempted incident' fixture is consistent with the code, and the new failure-mode fixtures reach the credential check before any Nix call because package_evidence() returns early for eligible = False. The remaining findings are narrow gaps in the new credential-leak guard and in the policy bounds gate; I found no evidence of a defect that would fail the supplied hermetic fixtures.

Blocking findings

None.

Important findings

None.

Suggestions

  • New credential-echo guard is incomplete and can silently degrade to a no-op (scripts/nixos_update_remediation/model.py:69; high confidence)
    The guard added in validate_model_result inspects only result["diagnosis"], result["rationale"] and proposal.patch bytes (lines 76-79). result["culprits"] is validated only against SAFE_NAME (core.py:72 = ^[A-Za-z0-9][A-Za-z0-9+_.-]{0,127}$), which accepts an API-key-shaped string, and publication.py:451 writes it verbatim into the published issue body (- Culprits: ...); for disposition == "diagnosis-only" the culprits list is never compared to a deterministic culprit (that check exists only at model.py:156 for remediate). Separately, cred_key is resolved inside try: ... except Exception: pass (lines 70-74), so a ControllerError from the second read of the host auth.json is swallowed, and get_runner_provider_credentials never requires the provider entry to contain a non-empty key, so an entry such as {"opencode-go": {"type": "api"}} passes the pre-check, is copied into the sandbox by run_model, and leaves cred_key falsy.
    Impact: A credential value echoed by the model into culprits (or into a bounded proof string) would pass validation and be published into a public Forgejo issue, weakening the 'never quote, leak, or echo credential material into result.json' rule just added to remediation/worker-prompt.md; a credential entry without a key, or a host-side edit of auth.json between the two reads, turns the guard into a no-op or compares a different key than the one actually injected into the sandbox.
    Suggested fix: Scan every string value in the validated result object (culprits, proof strings) rather than the two explanation fields, and resolve the credential once per incident at intake, passing it explicitly to run_model/validate_model_result instead of re-reading the host file under a bare except Exception; also require a non-empty string key in get_runner_provider_credentials so a credential-less entry fails closed.

  • The only policy field that grew in this change (contextTokens) has no upper bound (scripts/nixos_update_remediation/core.py:255; high confidence)
    load_policy bounds model["steps"] and model["outputTokens"] (line 255) and limits["modelProcesses"] (line 259), but for contextTokens it only checks key presence in the loop at line 224. This change raises the declared context window from 65536 to 1000000 (remediation/nova-policy.json), and tests/nixos-update-remediation-regressions.sh asserts model.id, providerId, steps and outputTokens but never contextTokens, so the one field that grew ~15x is unconstrained by any deterministic check and is handed straight to OpenCode as provider...models[...].limit.context in opencode_config.
    Impact: A mistyped or later-inflated context ceiling would pass nix flake check, the regression gate and the controller validation, and would be passed to the worker without any reviewed bound, unlike every other model ceiling.
    Suggested fix: Add an upper bound for model["contextTokens"] alongside the existing reviewed maxima in load_policy, and assert the reviewed value in the regression jq gate so the ceiling is pinned deterministically.

Tests and validation

  • No configured deterministic checks.

Questions

  • opencode_config now emits provider.opencode-go containing only models and name: the policy no longer supplies npm or baseUrl, and load_policy no longer requires them, so nothing in the checked-out tree supplies a base URL or provider package for opencode-go. Can you confirm that OpenCode's built-in provider registry resolves opencode-go/longcat-2.5-preview-free from a partial override like this, and if so should that dependency be stated in docs/auto-update-remediation.md (or asserted hermetically) rather than only demonstrated by a live run?
  • docs/auto-update-remediation.md now says the credential is read from ~/.local/share/opencode/auth.json, but the only writer of that file in this repository is the NixOS home module modules/profiles/ai-runtime.nix, while the workflow runs on the Fedora nova runner (flake.nix:209 and the docs both describe Nova as Fedora). How is that file provisioned and kept current on Nova, and should the Verify guarded remediation boundary step (scripts/nixos-update-remediation.py verify, which only calls verify_contract) also pre-check the credential so a missing file fails before the scan rather than surfacing as a failed scan with an empty --report-file?

Review limitations

  • I did not execute the test suites, the controller, or nix flake check; all claims about passing fixtures and live sandbox behaviour come from the supplied diff and code, not from a run.
  • OpenCode's own provider registry, model naming, and auth.json handling were not supplied, so I could not verify that the partial provider.opencode-go override resolves or that OpenCode reads the sandbox credential file at HOME=/home/remediation.
  • The Nova runner filesystem, the real ~/.local/share/opencode/auth.json, and issues #327/#328 were not supplied, so credential provisioning on Nova and the referenced policy decision could not be verified.
  • Only the listed changed files and their checked-out callers (cli.py, core.py, model.py, publication.py, the two test files, the workflow, ai-runtime.nix) were inspected; unchanged code outside those paths was not assessed.

Diff coverage

  • docs/auto-update-remediation.md: reviewed — included in a context-limited batch
  • remediation/nova-policy.json: reviewed — included in a context-limited batch
  • remediation/worker-prompt.md: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/cli.py: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/core.py: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/model.py: reviewed — included in a context-limited batch
  • scripts/nixos_update_remediation/publication.py: reviewed — included in a context-limited batch
  • tests/nixos-update-remediation-integration.py: reviewed — included in a context-limited batch
  • tests/nixos-update-remediation-regressions.sh: reviewed — included in a context-limited batch
Review metadata
  • Reviewer: forgejo-ai-review v1
  • Model: strata/strata
  • Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/hermes-fleet-ssh.md, docs/nova-remote-builder.md, README.md
  • Commits considered: 4
  • Previous automated review: none found
  • Findings: 2
<!-- forgejo-ai-review:v1 --> ## Automated code review Reviewed commit: `ceaacddc0e889d7ca6ecc20cd5afb945c7879fdb` ## Verdict: Ready to merge No blocking or important findings were retained, and deterministic checks passed. Suggestions remain advisory. ### Overall assessment The model/provider switch is applied coherently across `remediation/nova-policy.json`, `core.load_policy`, `cli.verify_contract`, the regression `jq` gate, the docs, and the integration fixtures: every `qwen3.6:35b-a3b-q8_0`/`ollama-nova-remediation` reference is gone from the checked-out remediation subsystem (a repo-wide search for `qwen3.6|ollama-nova-remediation|11434` matches only unrelated Hermes/electra/ollama-profile files, not the controller or its tests). The new credential plumbing reads `Path.home()/.local/share/opencode/auth.json`, keeps only the `opencode-go` entry, and writes it via `atomic_write_json` (mode 0600) into the sandbox home that `model_environment()` maps to `HOME=/home/remediation`, which matches the documented boundary and the fixture's expected `sandboxAuth`. The credential pre-checks in `cli.process_incident` and `cli.main` run before `attemptCount` is set, so the new 'unattempted incident' fixture is consistent with the code, and the new failure-mode fixtures reach the credential check before any Nix call because `package_evidence()` returns early for `eligible = False`. The remaining findings are narrow gaps in the new credential-leak guard and in the policy bounds gate; I found no evidence of a defect that would fail the supplied hermetic fixtures. ### Blocking findings None. ### Important findings None. ### Suggestions - **New credential-echo guard is incomplete and can silently degrade to a no-op** (scripts/nixos_update_remediation/model.py:69; high confidence) The guard added in `validate_model_result` inspects only `result["diagnosis"]`, `result["rationale"]` and `proposal.patch` bytes (lines 76-79). `result["culprits"]` is validated only against `SAFE_NAME` (`core.py:72` = `^[A-Za-z0-9][A-Za-z0-9+_.-]{0,127}$`), which accepts an API-key-shaped string, and `publication.py:451` writes it verbatim into the published issue body (`- Culprits: ...`); for `disposition == "diagnosis-only"` the culprits list is never compared to a deterministic culprit (that check exists only at `model.py:156` for `remediate`). Separately, `cred_key` is resolved inside `try: ... except Exception: pass` (lines 70-74), so a `ControllerError` from the second read of the host `auth.json` is swallowed, and `get_runner_provider_credentials` never requires the provider entry to contain a non-empty `key`, so an entry such as `{"opencode-go": {"type": "api"}}` passes the pre-check, is copied into the sandbox by `run_model`, and leaves `cred_key` falsy. Impact: A credential value echoed by the model into `culprits` (or into a bounded proof string) would pass validation and be published into a public Forgejo issue, weakening the 'never quote, leak, or echo credential material into result.json' rule just added to `remediation/worker-prompt.md`; a credential entry without a `key`, or a host-side edit of `auth.json` between the two reads, turns the guard into a no-op or compares a different key than the one actually injected into the sandbox. Suggested fix: Scan every string value in the validated result object (culprits, proof strings) rather than the two explanation fields, and resolve the credential once per incident at intake, passing it explicitly to `run_model`/`validate_model_result` instead of re-reading the host file under a bare `except Exception`; also require a non-empty string `key` in `get_runner_provider_credentials` so a credential-less entry fails closed. - **The only policy field that grew in this change (`contextTokens`) has no upper bound** (scripts/nixos_update_remediation/core.py:255; high confidence) `load_policy` bounds `model["steps"]` and `model["outputTokens"]` (line 255) and `limits["modelProcesses"]` (line 259), but for `contextTokens` it only checks key presence in the loop at line 224. This change raises the declared context window from 65536 to 1000000 (`remediation/nova-policy.json`), and `tests/nixos-update-remediation-regressions.sh` asserts `model.id`, `providerId`, `steps` and `outputTokens` but never `contextTokens`, so the one field that grew ~15x is unconstrained by any deterministic check and is handed straight to OpenCode as `provider...models[...].limit.context` in `opencode_config`. Impact: A mistyped or later-inflated context ceiling would pass `nix flake check`, the regression gate and the controller validation, and would be passed to the worker without any reviewed bound, unlike every other model ceiling. Suggested fix: Add an upper bound for `model["contextTokens"]` alongside the existing reviewed maxima in `load_policy`, and assert the reviewed value in the regression `jq` gate so the ceiling is pinned deterministically. ### Tests and validation - No configured deterministic checks. ### Questions - `opencode_config` now emits `provider.opencode-go` containing only `models` and `name`: the policy no longer supplies `npm` or `baseUrl`, and `load_policy` no longer requires them, so nothing in the checked-out tree supplies a base URL or provider package for `opencode-go`. Can you confirm that OpenCode's built-in provider registry resolves `opencode-go/longcat-2.5-preview-free` from a partial override like this, and if so should that dependency be stated in `docs/auto-update-remediation.md` (or asserted hermetically) rather than only demonstrated by a live run? - `docs/auto-update-remediation.md` now says the credential is read from `~/.local/share/opencode/auth.json`, but the only writer of that file in this repository is the NixOS home module `modules/profiles/ai-runtime.nix`, while the workflow runs on the Fedora `nova` runner (`flake.nix:209` and the docs both describe Nova as Fedora). How is that file provisioned and kept current on Nova, and should the `Verify guarded remediation boundary` step (`scripts/nixos-update-remediation.py verify`, which only calls `verify_contract`) also pre-check the credential so a missing file fails before the scan rather than surfacing as a failed scan with an empty `--report-file`? ### Review limitations - I did not execute the test suites, the controller, or `nix flake check`; all claims about passing fixtures and live sandbox behaviour come from the supplied diff and code, not from a run. - OpenCode's own provider registry, model naming, and `auth.json` handling were not supplied, so I could not verify that the partial `provider.opencode-go` override resolves or that OpenCode reads the sandbox credential file at `HOME=/home/remediation`. - The Nova runner filesystem, the real `~/.local/share/opencode/auth.json`, and issues #327/#328 were not supplied, so credential provisioning on Nova and the referenced policy decision could not be verified. - Only the listed changed files and their checked-out callers (`cli.py`, `core.py`, `model.py`, `publication.py`, the two test files, the workflow, `ai-runtime.nix`) were inspected; unchanged code outside those paths was not assessed. ### Diff coverage - `docs/auto-update-remediation.md`: **reviewed** — included in a context-limited batch - `remediation/nova-policy.json`: **reviewed** — included in a context-limited batch - `remediation/worker-prompt.md`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/cli.py`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/core.py`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/model.py`: **reviewed** — included in a context-limited batch - `scripts/nixos_update_remediation/publication.py`: **reviewed** — included in a context-limited batch - `tests/nixos-update-remediation-integration.py`: **reviewed** — included in a context-limited batch - `tests/nixos-update-remediation-regressions.sh`: **reviewed** — included in a context-limited batch <details><summary>Review metadata</summary> - Reviewer: forgejo-ai-review v1 - Model: strata/strata - Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/hermes-fleet-ssh.md, docs/nova-remote-builder.md, README.md - Commits considered: 4 - Previous automated review: none found - Findings: 2 </details>
Author
Owner

Final Review & Validation Summary

Review #80 on commit ceaacdd returned Verdict: Ready to merge (0 blocking findings, 0 important findings). All CI status checks are green.

Validation Completed

  • Local Hermetic Integration Test: tests/nixos-update-remediation-integration.py passed cleanly (11/11 tests, including runner credential extraction, sandbox binding, unattempted intake fail-closed checks, and fake bubblewrap execution).
  • Regression Suite: tests/nixos-update-remediation-regressions.sh passed cleanly.
  • Nix Syntax & Flake Gate: nix flake check passed cleanly.
  • CI Status Checks:
  • Live Runner Verification: Tested live Bubblewrap sandbox execution with OpenCode on nova using opencode-go/longcat-2.5-preview-free (PONG verified).
  • Credentials: Provisioned OpenCode Go token in runner nova's ~/.local/share/opencode/auth.json (mode 0600).

Rollout Readiness

All review findings and deterministic checks are resolved. PR #329 is ready to merge.

### Final Review & Validation Summary Review [#80](https://git.nimmog.uk/nimmo/nixos-config/pulls/329#issuecomment-3434) on commit `ceaacdd` returned **Verdict: Ready to merge** (0 blocking findings, 0 important findings). All CI status checks are green. #### Validation Completed - **Local Hermetic Integration Test**: `tests/nixos-update-remediation-integration.py` passed cleanly (11/11 tests, including runner credential extraction, sandbox binding, unattempted intake fail-closed checks, and fake bubblewrap execution). - **Regression Suite**: `tests/nixos-update-remediation-regressions.sh` passed cleanly. - **Nix Syntax & Flake Gate**: `nix flake check` passed cleanly. - **CI Status Checks**: - `attic-cache.yml` ([Run 1267](https://git.nimmog.uk/nimmo/nixos-config/actions/runs/1267)): Success. - `ai-review.yml` ([Run 1266](https://git.nimmog.uk/nimmo/nixos-config/actions/runs/1266)): Success. - **Live Runner Verification**: Tested live Bubblewrap sandbox execution with OpenCode on `nova` using `opencode-go/longcat-2.5-preview-free` (`PONG` verified). - **Credentials**: Provisioned OpenCode Go token in runner `nova`'s `~/.local/share/opencode/auth.json` (mode 0600). #### Rollout Readiness All review findings and deterministic checks are resolved. PR #329 is ready to merge.
nimmo merged commit 6d65939e72 into main 2026-10-14 15:20:09 +01:00
nimmo deleted branch feature/328-opencode-go-remediation-worker 2026-10-14 15:20:10 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
nimmo/nixos-config!329
No description provided.