feat(remediation): switch worker to OpenCode Go longcat-2.5-preview-free #329
No reviewers
Labels
No labels
area:authentication
area:flake-utilities
area:performance
area:tbd
host:chaos
host:cosmos
host:electra
host:fleet
host:lena
host:lyra
host:mass-storage
host:media1
host:nimmog-de
host:nova
host:pangolin
host:pangolin-vps
host:phone
host:router
host:vega
investigation
phase:cutover
phase:deploy
phase:mcp
phase:module
phase:packaging
phase:prep
phase:validation
priority:high
priority:medium
project:attic-postgres-lyra-rollout
project:auto-update-reliability
project:auto-update-remediation
project:declarative-purity-cleanup
project:external-review
project:fleet-boundary-cleanup
project:host-facts-refactor
project:lyra-nixos-deploy
project:lyra-service-stack-migration
project:nebula-mesh-network
project:nix-idioms-hygiene
project:nixos-build-deployment-pipeline
project:security-hardening
project:service-stack-migration
project:vega-sillytavern-cutover
project:wiki-rebuild
repo:numtide/flake-utils
repo:numtide/nix-auth
repo:numtide/nixos-passthru-cache
repo:numtide/nix-relay
service:auto-update
service:gitlab
service:hermes
service:mem0
service:nix
service:sillytavern
service:slskd
service:synthseek
service:tdarr
No milestone
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
nimmo/nixos-config!329
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/328-opencode-go-remediation-worker"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs #328.
Summary
Switches the automated update remediation worker from local Ollama (
qwen3.6:35b-a3b-q8_0) to OpenCode Go with modellongcat-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-freeprovides 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
remediation/nova-policy.json): ConfiguredproviderId: "opencode-go",id: "longcat-2.5-preview-free", 1M context tokens.scripts/nixos_update_remediation/model.py): Injected filtered runner credentials (opencode,opencode-go) into/home/remediation/.local/share/opencode/auth.jsoninside Bubblewrap while strictly filtering out unrelated host credentials.scripts/nixos_update_remediation/core.py&cli.py): Updated deterministic model validation.docs/auto-update-remediation.md): Updated worker model specifications.tests/nixos-update-remediation-regressions.sh&tests/nixos-update-remediation-integration.py): Updated assertions and verified test suite passes.Validation
PONGverified)../tests/nixos-update-remediation-regressions.shpassed../tests/nixos-pin-lifecycle-regressions.shpassed.nix flake checkpassed.python3 -m py_compileandshellcheckpassed.Automated code review
Reviewed commit:
c271a025cd1fe7e340813e00cb6b1e6bbe21f03cVerdict: 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 regressionjqgate, and the integration fixture: all move tolongcat-2.5-preview-free/opencode-gotogether, andremediation/worker-prompt.mdcontains 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 inmodel.py(lines 595-612), which copies a hard-coded subset of the runner's~/.local/share/opencode/auth.jsoninto 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'sproviderId, is not covered by the hermetic fixtures, and is not described in the boundary paragraph ofdocs/auto-update-remediation.md. I could not runnix 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
The new block (model.py:595-612) wraps the read,
json.load, andatomic_write_jsonintry: ... 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) raisesControllerError, which that bare handler also swallows. Unlike the previous loopback Ollama worker,opencode-gois an authenticated provider (secrets/README.md:232documentsopencode-go-api-keybeing merged intoauth.jsonas theopencode-goprovider 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
ControllerErrornaming the cause (missingopencode-gokey in the runner'sauth.json, unparseable file, or failed sandbox write) instead of swallowing the exception, and treat an empty filtered credential set for the authenticatedpolicy["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"], whileremediation/nova-policy.jsonselects onlyproviderId: "opencode-go".modules/profiles/ai-runtime.nix:348-354shows the activation writingopenrouter,opencode-go, andpangolin-lyraentries intoauth.json(correctly excluded), so the extra admitted keyopencodeis 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-netenabled), and the published model text fields pass only throughsanitise_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 theopencodeaccount entry is additionally required for anopencode-gorequest), 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_boundaryasserts only on recordedenvkeys and the generated OpenCode config; nothing asserts thatauth.jsonexists at<sandbox home>/.local/share/opencode/auth.json, that it is filtered, or that unrelated keys are excluded. The fixture invokes the controller withcontroller_env = os.environ.copy()(test line 1033), soPath.home()in model.py:597 resolves to the machine running the test, whiledocs/auto-update-remediation.md:175states 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.jsonunder a fixture-controlledHOMEcontaining 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
authfrom "normal OpenCode auth/config". Nothing in the paragraph states that model.py:595-612 now copies the runner's filteredopencode/opencode-gocredential 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
Questions
~/.local/share/opencode/auth.jsonprovisioned?docs/nova-remote-builder.mddescribes Nova as a Fedora host not registered in the flake, and theopencode-goentry is normally written by the home-manager activation inmodules/profiles/ai-runtime.nix:348-354;potential/nova/default.nixcontains noai-runtimeor opencode profile. Please confirm theremediatejob'sHOMEactually contains anopencode-gokey, since the code silently proceeds without it."npm": "@ai-sdk/openai-compatible"fromremediation/nova-policy.jsonwhile omittingoptions.baseURL(the policy no longer carriesbaseUrl, andopencode_confignow emits that key only conditionally)? OpenCode's provider/auth registry is not in this checkout, so I cannot confirm that anopencode-goentry without abaseURLresolves to the correct endpoint and auth flow.opencodeauth entry required for anopencode-gorequest, or is theopencode-gokey alone sufficient? The filter admits both.contextTokensis now 1000000 whilelimits.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
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 returnedPONGare unverified PR text.Path.home()resolves to a home containing anopencode-goentry, nor the file's ownership/mode as seen by the sandbox uid 65534.opencode-go/opencodeprovider definitions are not in this checkout, so I cannot verify the generatedprovider/modelsconfig resolves to a working authenticated endpoint forlongcat-2.5-preview-free.scripts/nova-remediation-benchmark.py,benchmarks/nova-remediation/, andtests/nova-remediation-benchmark.share referenced by.forgejo/workflows/attic-cache.ymlpath filters but are absent from this checkout, so I could not assess whether they still assume the previous local model.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 batchremediation/nova-policy.json: reviewed — included in a context-limited batchscripts/nixos_update_remediation/cli.py: reviewed — included in a context-limited batchscripts/nixos_update_remediation/core.py: reviewed — included in a context-limited batchscripts/nixos_update_remediation/model.py: reviewed — included in a context-limited batchscripts/nixos_update_remediation/publication.py: reviewed — included in a context-limited batchtests/nixos-update-remediation-integration.py: reviewed — included in a context-limited batchtests/nixos-update-remediation-regressions.sh: reviewed — included in a context-limited batchReview metadata
Automated code review
Reviewed commit:
af5504535ec54672f7c231a795371d7c933aa552Verdict: 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-freeprovider 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 intests/nixos-update-remediation-regressions.sh, and the integration fixture's model/provider assertions all agree, and no staleqwen3.6:35b-a3b-q8_0orollama-nova-remediationreference remains in the controller or its tests. The new credential plumbing inmodel.pyreads only the configured provider key out of the runner's~/.local/share/opencode/auth.jsonand writes it atshare_home/opencode/auth.json, which matches the sandbox'sHOME/XDG_DATA_HOMEinmodel_environment(), at mode 0600 viaatomic_write_json(defaultmode=0o600incore.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-objectauth.jsonraises aTypeErrorthat escapes the controller'sControllerErrorcontract and aborts the whole scan; and the policy still carries the Ollama-specificnpmvalue while thebaseUrlthat accompanied it was deleted, so the generated provider block for the built-inopencode-godeclares 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
The new credential block checks only
host_auth_file.is_file(), thatjson.loadsucceeds, andif provider_id not in host_auth:before doingatomic_write_json(data_opencode / "auth.json", {provider_id: host_auth[provider_id]}). Nothing assertshost_authis a dict. A parseable non-object document satisfiesin(a top-level string containingopencode-go, or an array containing it) and thenhost_auth[provider_id]raisesTypeError: string indices must be integers/list indices must be integers; for a number, theintest itself raisesTypeError: argument of type 'int' is not iterable.cli.pycatches onlyControllerErroraroundrun_model(except ControllerError as exc: result = fallback_result(...), cli.py:154) and only(ControllerError, BlockingIOError)per incident in the scan loop (cli.py:442), andentrypointcatches onlyTerminationRequested/ControllerError(cli.py:459-466), so aTypeErrorunwinds all three. The repository already ships a stricter reader,core.py:read_json, which raisesControllerErroronOSError/UnicodeDecodeError/json.JSONDecodeErrorand rejects duplicate keys viaobject_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 atadvisory-attempt-started.Suggested fix: Validate the parsed credential document as a JSON object before indexing it and raise
ControllerErrorotherwise (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 existingfrom .core import read_jsonhelper already imported bymodel.pyso the failure follows the bounded-diagnosis path instead of escaping the controller's error contract.Suggestions
npmwhile itsbaseUrlwas removed, generating a provider override with no endpoint (scripts/nixos_update_remediation/model.py:255; medium confidence)opencode_confignow emits**({"npm": model["npm"]} if "npm" in model else {})and**({"options": {"baseURL": model["baseUrl"]}} if "baseUrl" in model else {}).remediation/nova-policy.jsondeletes"baseUrl": "http://127.0.0.1:11434/v1"but keeps"npm": "@ai-sdk/openai-compatible", so the generated config declaresprovider.opencode-gowith an OpenAI-compatible client and nooptions.baseURL. Every other explicit provider definition in the repository pairs the two keys (modules/profiles/ai-runtime.nix:189andhosts/electra/default.nix:90setnpmtogether withoptions.baseURL), whereasopencode-gois otherwise used only as a built-in provider with noproviderblock at all:modules/profiles/ai-runtime.nix:153lists it inenabled_providersand its credential is merged atai-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
providerentry as a definition rather than an overlay on the built-inopencode-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
npmfromremediation/nova-policy.jsonforopencode-goso the built-in provider definition is inherited, or state the OpenCode Go base URL explicitly in the policy; the conditional injection inopencode_configalready supports omitting either key.Tests and validation
Questions
~/.local/share/opencode/auth.jsonwith anopencode-goentry?potential/nova/default.niximportsmodules/profiles/ai-agents.nix(which contains noopencodereference) andmodules/profiles/ollama.nix, notmodules/profiles/ai-runtime.nix, which is the only place in the flake that merges anopencode-gocredential into that file; the workflow's bootstrap step only teststest -x /home/nimmo/.opencode/bin/opencode(attic-cache.yml:315), so the new fail-closed check would surface only mid-scan.remediation/worker-prompt.mdbe 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_contractasserts only four other boundary strings, so nothing would catch the drift.XDG_DATA_HOMErather than a hardcoded.local/share/opencodeunderPath.home()? The workflow overridesXDG_CONFIG_HOMEfor the scan (attic-cache.yml:345) but notXDG_DATA_HOME, so the current hardcoded path matches the runner today.Review limitations
auth.json; provider-definition overlay semantics and credential provisioning could not be verified.nix flake check, the regression script, and the integration test were not run; the PR's validation claims are treated as untrusted evidence.Diff coverage
docs/auto-update-remediation.md: reviewed — included in a context-limited batchremediation/nova-policy.json: reviewed — included in a context-limited batchscripts/nixos_update_remediation/cli.py: reviewed — included in a context-limited batchscripts/nixos_update_remediation/core.py: reviewed — included in a context-limited batchscripts/nixos_update_remediation/model.py: reviewed — included in a context-limited batchscripts/nixos_update_remediation/publication.py: reviewed — included in a context-limited batchtests/nixos-update-remediation-integration.py: reviewed — included in a context-limited batchtests/nixos-update-remediation-regressions.sh: reviewed — included in a context-limited batchReview metadata
Automated Review Response (Commit
d5a02a8)Thank you for the review feedback on commit
af55045. All actionable findings have been resolved ind5a02a8:Non-object runner auth.json validation (Important finding):
scripts/nixos_update_remediation/model.pywith the repository's strictread_jsonhelper fromcore.py(which rejects duplicate keys and handles decoding errors).isinstance(host_auth, dict)guard that raisesControllerError(f"runner credentials file at {host_auth_file} is not a JSON object")to ensure non-dict payloads fail closed cleanly instead of raising unhandledTypeErrors during scan loops.tests/nixos-update-remediation-integration.pyexercisingrun_modelwith string, array, and int payloads, proving they all fail closed cleanly withControllerError.Policy provider definition (Suggestion):
"npm": "@ai-sdk/openai-compatible"fromremediation/nova-policy.json.opencode-go. Dropping the unused NPM override allows OpenCode to inherit its native provider definition directly without constructing an endpoint-less OpenAI-compatible overlay.Worker prompt boundary clarification (Question):
remediation/worker-prompt.mdtrust-boundary text to clarify that host user homes, Attic/deployment credentials, and unrelated secrets are deliberately unavailable.Nova Runner Provisioning (Question):
~/.local/share/opencode/auth.json(mode 0600) is provisioned on the Nova runner and verified against the live Bubblewrap container with modelopencode-go/longcat-2.5-preview-free(PONGverified).Automated code review
Reviewed commit:
d5a02a8be05024302e6f7895364da59c1f1581edVerdict: 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
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/opencodeand./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
Questions
npmnoroptions.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.Review limitations
Diff coverage
docs/auto-update-remediation.md: reviewed — included in a context-limited batchremediation/nova-policy.json: reviewed — included in a context-limited batchremediation/worker-prompt.md: reviewed — included in a context-limited batchscripts/nixos_update_remediation/cli.py: reviewed — included in a context-limited batchscripts/nixos_update_remediation/core.py: reviewed — included in a context-limited batchscripts/nixos_update_remediation/model.py: reviewed — included in a context-limited batchscripts/nixos_update_remediation/publication.py: reviewed — included in a context-limited batchtests/nixos-update-remediation-integration.py: reviewed — included in a context-limited batchtests/nixos-update-remediation-regressions.sh: reviewed — included in a context-limited batchReview metadata
Automated Review Response (Commit
ceaacdd)Thank you for the detailed review on commit
d5a02a8. All findings have been addressed inceaacdd:Pre-attempt Credential Validation (Important finding):
get_runner_provider_credentials(policy)inscripts/nixos_update_remediation/model.py.process_incident(scripts/nixos_update_remediation/cli.py), runner credentials are now validated beforestate.update({"attemptCount": 1, ...}). If runner credentials are missing or corrupted, the controller raisesControllerErrorwithout consuming the incident attempt budget or persisting an erroneous diagnosis-only outcome.cmd_scan, runner credentials are also validated upfront whenever incidents are queued, failing the scan job before touching any incident.tests/nixos-update-remediation-integration.pyproving that a broken runner auth file leavesremediation-state.jsonunattempted (attemptCountnot incremented).Bounded Auth Read & Shape Validation (Suggestion):
get_runner_provider_credentialspasses an explicit64 * 1024byte bound toread_json.host_authandhost_auth[provider_id]are valid JSON dicts.Trust Boundary Text & Credential Leak Guard (Suggestion):
remediation/worker-prompt.mdto explicitly state:validate_model_result(scripts/nixos_update_remediation/model.py) that checksresult["diagnosis"],result["rationale"], andpatch_pathfor the runner credential string and rejects the proposal if credential material is echoed.Automated code review
Reviewed commit:
ceaacddc0e889d7ca6ecc20cd5afb945c7879fdbVerdict: 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 regressionjqgate, the docs, and the integration fixtures: everyqwen3.6:35b-a3b-q8_0/ollama-nova-remediationreference is gone from the checked-out remediation subsystem (a repo-wide search forqwen3.6|ollama-nova-remediation|11434matches only unrelated Hermes/electra/ollama-profile files, not the controller or its tests). The new credential plumbing readsPath.home()/.local/share/opencode/auth.json, keeps only theopencode-goentry, and writes it viaatomic_write_json(mode 0600) into the sandbox home thatmodel_environment()maps toHOME=/home/remediation, which matches the documented boundary and the fixture's expectedsandboxAuth. The credential pre-checks incli.process_incidentandcli.mainrun beforeattemptCountis 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 becausepackage_evidence()returns early foreligible = 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_resultinspects onlyresult["diagnosis"],result["rationale"]andproposal.patchbytes (lines 76-79).result["culprits"]is validated only againstSAFE_NAME(core.py:72=^[A-Za-z0-9][A-Za-z0-9+_.-]{0,127}$), which accepts an API-key-shaped string, andpublication.py:451writes it verbatim into the published issue body (- Culprits: ...); fordisposition == "diagnosis-only"the culprits list is never compared to a deterministic culprit (that check exists only atmodel.py:156forremediate). Separately,cred_keyis resolved insidetry: ... except Exception: pass(lines 70-74), so aControllerErrorfrom the second read of the hostauth.jsonis swallowed, andget_runner_provider_credentialsnever requires the provider entry to contain a non-emptykey, so an entry such as{"opencode-go": {"type": "api"}}passes the pre-check, is copied into the sandbox byrun_model, and leavescred_keyfalsy.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 toremediation/worker-prompt.md; a credential entry without akey, or a host-side edit ofauth.jsonbetween 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_resultinstead of re-reading the host file under a bareexcept Exception; also require a non-empty stringkeyinget_runner_provider_credentialsso 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_policyboundsmodel["steps"]andmodel["outputTokens"](line 255) andlimits["modelProcesses"](line 259), but forcontextTokensit 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), andtests/nixos-update-remediation-regressions.shassertsmodel.id,providerId,stepsandoutputTokensbut nevercontextTokens, so the one field that grew ~15x is unconstrained by any deterministic check and is handed straight to OpenCode asprovider...models[...].limit.contextinopencode_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 inload_policy, and assert the reviewed value in the regressionjqgate so the ceiling is pinned deterministically.Tests and validation
Questions
opencode_confignow emitsprovider.opencode-gocontaining onlymodelsandname: the policy no longer suppliesnpmorbaseUrl, andload_policyno longer requires them, so nothing in the checked-out tree supplies a base URL or provider package foropencode-go. Can you confirm that OpenCode's built-in provider registry resolvesopencode-go/longcat-2.5-preview-freefrom a partial override like this, and if so should that dependency be stated indocs/auto-update-remediation.md(or asserted hermetically) rather than only demonstrated by a live run?docs/auto-update-remediation.mdnow 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 modulemodules/profiles/ai-runtime.nix, while the workflow runs on the Fedoranovarunner (flake.nix:209and the docs both describe Nova as Fedora). How is that file provisioned and kept current on Nova, and should theVerify guarded remediation boundarystep (scripts/nixos-update-remediation.py verify, which only callsverify_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
nix flake check; all claims about passing fixtures and live sandbox behaviour come from the supplied diff and code, not from a run.auth.jsonhandling were not supplied, so I could not verify that the partialprovider.opencode-gooverride resolves or that OpenCode reads the sandbox credential file atHOME=/home/remediation.~/.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.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 batchremediation/nova-policy.json: reviewed — included in a context-limited batchremediation/worker-prompt.md: reviewed — included in a context-limited batchscripts/nixos_update_remediation/cli.py: reviewed — included in a context-limited batchscripts/nixos_update_remediation/core.py: reviewed — included in a context-limited batchscripts/nixos_update_remediation/model.py: reviewed — included in a context-limited batchscripts/nixos_update_remediation/publication.py: reviewed — included in a context-limited batchtests/nixos-update-remediation-integration.py: reviewed — included in a context-limited batchtests/nixos-update-remediation-regressions.sh: reviewed — included in a context-limited batchReview metadata
Final Review & Validation Summary
Review #80 on commit
ceaacddreturned Verdict: Ready to merge (0 blocking findings, 0 important findings). All CI status checks are green.Validation Completed
tests/nixos-update-remediation-integration.pypassed cleanly (11/11 tests, including runner credential extraction, sandbox binding, unattempted intake fail-closed checks, and fake bubblewrap execution).tests/nixos-update-remediation-regressions.shpassed cleanly.nix flake checkpassed cleanly.attic-cache.yml(Run 1267): Success.ai-review.yml(Run 1266): Success.novausingopencode-go/longcat-2.5-preview-free(PONGverified).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.