Repository navigation
fix(opencode): track .opencode plugin dependency manifest - #48
Conversation
.opencode/plugin/codex-web-search.ts imports @opencode-ai/plugin at runtime, but nothing declared that dependency for OpenCode's own plugin-dependency installer to act on: .opencode/package.json existed only as an untracked local file, so a fresh checkout (any clone, and every CI run) never has it. Without the manifest, the opencode CLI's plugin loader cannot resolve @opencode-ai/plugin when it discovers this project plugin, and session creation dies with a generic 500 (UnknownError) before any model turn starts. This broke the pr-review CI job (run 32226447284) as soon as the plugin landed on develop, and would break any fresh clone the same way. Commit the manifest so OpenCode installs the dependency on startup, and add a scoped .gitignore so future node_modules/package-lock.json/ bun.lock churn under .opencode/ doesn't get committed by mistake.
Local repro of the PR #48 fix (fresh checkout, matching OPENCODE_DISABLE_PROJECT_CONFIG and OPENCODE_PERMISSION) succeeds, but CI still fails the same way after the fix merged in this branch. Surface the CLI's own error-level logs in the job output so the next run shows the real cause instead of just the generic 500.
The diagnostic logging served its purpose: it revealed the actual failure is ProviderModelNotFoundError for anthropic/claude-sonnet-5, unrelated to this PR (REVIEWER_MODEL has not resolved successfully in any pr-review run since it was set to claude-sonnet-5@max on 2026-08-17, independent of the plugin manifest fix below). Leaving --print-logs on unconditionally would permanently surface internal CLI error detail in this public repo's Actions logs for every future review, which wasn't a deliberate decision to make as part of this fix.
There was a problem hiding this comment.
The delegated review task returned no output or findings. Direct review of PR #48 found:
- [P1]
.opencode/package.json:2-4:OPENCODE_DISABLE_PROJECT_CONFIG=1excludes the checkout’s.opencodedirectory from dependency installation duringpr-review, so this manifest cannot fix the claimed CI plugin-resolution issue. - [P2]
.opencode/package.json:3: UsingREVIEWER_OPENCODE_VERSIONcan cause OpenCode’s installer to rewrite this tracked dependency, and prompt-based runs may auto-commit that generated change. - [P2]
.github/actions/run-opencode/action.yml:293-294: Debug logging remains enabled in the final diff despite the PR description saying it was reverted, exposing internal error details in public Actions logs.
Caught by the automated review on this PR: --print-logs/--log-level ERROR were re-added while diagnosing the ProviderModelNotFoundError and never reverted a second time, leaving internal CLI error detail permanently exposed in this public repo's Actions logs. action.yml now matches develop exactly outside of the two intended files (.opencode/package.json, .opencode/.gitignore).
There was a problem hiding this comment.
Task Tool Summary
- Found one P2 issue at
.opencode/package.json:3. - No other findings.
Verified Finding
When REVIEWER_OPENCODE_VERSION differs from 1.18.18, OpenCode may rewrite the tracked plugin dependency during startup. Prompt-based runs automatically commit and push dirty files, potentially adding an unrelated manifest change to the PR.
Keep the manifest synchronized without mutating tracked configuration at startup.
anthropic/claude-sonnet-5 (and every other current Anthropic model, old and new) fails to resolve through OpenCode's built-in Anthropic OAuth provider — a known, still-open upstream bug where the built-in provider rejects valid model IDs until a new release updates its allowlist (anomalyco/opencode#21019). This repo's own opencode.jsonc already works around it locally via @ex-machina/opencode-anthropic-auth, but OPENCODE_DISABLE_PROJECT_CONFIG=1 correctly excludes that file in CI so a PR can't load arbitrary plugins with this job's credentials. Verified locally (isolated /Users/chris, no personal config, matching CI's disabled project config and restrictive permissions): model resolution for anthropic/claude-sonnet-5@max fails without this plugin and succeeds with it, in every case tested. Inject just this one version-pinned plugin via OPENCODE_CONFIG_CONTENT, which applies independent of on-disk project config, so the workflow re-enables the specific fix it already trusts without reopening the checkout as a plugin-loading vector. OPENCODE_PERMISSION is untouched: this only adds the auth plugin, not the project's own permissive 'permission: allow' default.
There was a problem hiding this comment.
Review Summary: PR #48
Scope creep flag: The PR is titled as fixing .opencode plugin dependency tracking, but 1 of 3 changed files is unrelated to that purpose.
✅ Clean: .opencode/package.json and .opencode/.gitignore correctly address the stated goal — dependency version (1.18.18) matches the pinned CLI version.
.github/actions/run-opencode/action.yml:282-294
This hunk unconditionally injects a plugin (@ex-machina/[email protected]) into every opencode run invocation in the CI review path — right next to code whose comments explicitly explain why plugin loading from untrusted sources is disabled (OPENCODE_DISABLE_PROJECT_CONFIG=1).
Three concrete issues:
- Unconditional despite being provider-specific — the plugin is only needed for Anthropic OAuth, but it loads regardless of which model/provider is active. The PR's own description says
REVIEWER_MODELis currently set to a non-Anthropic model, so it's dead weight right now. - Contradicts the adjacent security rationale — plugins execute as in-process code, bypassing the
OPENCODE_PERMISSIONdeny-by-default policy set nearby. A supply-chain compromise of the@ex-machinapackage would have ambient access to whatever CI credential is loaded that run. - Inconsistent with the PR's stated fix — the description says switching
REVIEWER_MODELaway from Anthropic "sidesteps the broken OAuth path entirely," but the diff still wires up the Anthropic-OAuth plugin unconditionally.
Severity: Bounded — fork PRs already have the reviewer disabled (_review-model.yml:114-117), so this isn't externally exploitable. Risk is a background supply-chain concern (compromise of the pinned package), not immediate. Recommendation: confirm this is intentional, and if so, gate it on $PROVIDER == "anthropic" rather than running on every invocation.
Want me to open a PR comment with this feedback, or make the suggested fix (gating the plugin injection on the Anthropic provider)?
Per review feedback on this PR: the plugin was loading unconditionally regardless of which provider REVIEWER_MODEL selects, which is dead weight (and unnecessary in-process plugin surface) for any non-Anthropic model. Gate it on $MODEL's provider prefix instead.
There was a problem hiding this comment.
Review Summary: PR #48
No bugs found. The changes add a .opencode/package.json and .opencode/.gitignore, plus a 19-line addition to .github/actions/run-opencode/action.yml that exports OPENCODE_CONFIG_CONTENT when the model provider is anthropic.
Verified as correct:
@opencode-ai/[email protected]is a valid published version matching the CLI pin elsewhere in the same file, and its exports satisfy the@opencode-ai/plugin/toolimport used bycodex-web-search.ts..opencode/sits outside the bun workspace glob, so pinning a real registry version (notworkspace:*) is correct.- The custom
.gitignoredeliberately excludespackage.jsonfrom ignored paths — this preempts the config loader's auto-generated.gitignore(which would otherwise ignorepackage.jsonand prevent it from being tracked). Subtle but handled correctly. - The new
if [ "${MODEL%%/*}" = "anthropic" ]block follows the existingPROVIDER="${MODEL%%/*}"pattern, runs in the same shell as the lateropencode runcall, and doesn't collide with other exports. - The other non-OpenAI provider (
opencode-go) uses plain API-key auth, not OpenCode's Anthropic OAuth provider, so it's correctly excluded from this workaround.
One informational note (not a bug, low confidence): The pre-existing (unmodified) auto-installer in packages/hena/src/config/config.ts runs npmSvc.install with no version pin whenever node_modules is missing in a project config dir. If npm/Arborist's unversioned add resolves to latest and rewrites package.json, the committed 1.18.18 pin could theoretically get overwritten on a fresh checkout's first install. This is pre-existing logic outside this PR's diff — worth a quick sanity check post-merge, not a blocker.
packages/hena/test/tool/truncation.test.ts's cleanup test was failing deterministically (100% reproducible, not flaky): Identifier.create shifts the millisecond timestamp left 12 bits to make room for a per-millisecond counter, but only allocated 6 bytes (48 bits) to store the result. Any real-world date past ~1972 needs more than 48 bits once shifted, so the encoding silently overflowed and Identifier.timestamp decoded garbage — e.g. a 2026 date round-tripped to 1970. For most callers this went unnoticed since ascending IDs are mainly compared to each other for ordering, and nearby real-time values still sorted consistently after wrapping. Truncate.cleanup() is the one caller that decodes absolute timestamps for a multi-day retention comparison, and 'now' currently sits within the ~10-day window where the 48-bit wraparound crosses between the cutoff and a file that should be kept — hence the deterministic (not flaky) failure. This recurs for about 10 days every ~2.18 years (2^36 ms) as real time crosses each wrap boundary. Fix: widen the encoding to 7 bytes (56 bits), enough for a 44-bit timestamp (safe past year 2500) plus the 12-bit counter. Total ID length is unchanged (26 chars after the prefix); the random suffix shrinks from 14 to 12 characters to make room. Added test/id/id.test.ts to lock in the round-trip and pin the regression (verified it fails without the fix, on the exact old/cutoff timestamps that broke truncation.test.ts). Unrelated to this fix: a full local bun test v1.3.14 (0d9b296a) run also intermittently fails test/server/session-messages.test.ts with a 404 (port/resource contention under high parallelism) — confirmed it passes 5/5 in isolation and is unaffected by this change.
There was a problem hiding this comment.
Code Review Summary — PR #48
One bug found (Medium severity):
The ID format change in packages/hena/src/id/id.ts widens the encoded timestamp from 6 bytes to 7 bytes to fix a real overflow issue — that part is correct. However, this breaks parsing of pre-existing on-disk IDs created before the change.
Truncate.cleanup()(packages/hena/src/tool/truncate.ts:54-66) reads real filenames from a persistent XDG data directory and callsIdentifier.timestamp()on them.- Old-format filenames have 12 hex chars where the new code expects 14, so it slices in 2 extra characters from the old random suffix.
- Since only ~35% of the base62 alphabet is valid hex, there's a high chance (~87%) this throws
SyntaxErrorfromBigInt("0x" + hex). - This throw happens in a plain loop (not per-entry handling), so it aborts the entire
cleanup()call. Since the failure is only logged (not retried), retention cleanup silently breaks on every subsequent run for anyone upgrading in place with existingtool-outputfiles. - Only affects upgrades, not fresh installs.
Suggested fix: Make Truncate.cleanup() tolerate unparseable entries (treat parse failures as "eligible for deletion" or skip+log) rather than letting the exception propagate.
Everything else checked out fine:
.github/actions/run-opencode/action.yml— consistent with existing patterns.opencode/package.json/.gitignore— version pins match, minor redundant (harmless) gitignore entry- New tests in
id.test.ts— good coverage for the overflow fix, but missing a test for legacy-format ID parsing (the gap causing the bug above)
Let me know if you'd like me to implement the suggested fix in truncate.ts.
There was a problem hiding this comment.
Review Summary: PR #48
One real bug found, plus a note on a dormant duplicate issue elsewhere in the codebase.
🐛 Bug: ID encoding change breaks cleanup for pre-existing files
packages/hena/src/id/id.ts widens the timestamp encoding from 6→7 bytes (12→14 hex chars), which is correct on its own. But it changes the ID layout while keeping total length the same (26 chars), so old-format and new-format IDs are indistinguishable by length alone.
Impact chain:
Truncate.cleanup()reads existing filenames from a persistent data dir (Global.Path.data/tool-output) — not a temp dir, so pre-upgrade files will still be present.- It calls
Identifier.timestamp(entry)on each filename with no local error handling. - For any file written before this fix, the new parser reads 14 hex chars where only 12 are valid — the rest are leftover base62 random-suffix characters. Since most base62 chars aren't valid hex,
BigInt("0x" + hex)throws ~87% of the time. - That uncaught throw aborts the entire
forloop incleanup(), not just the one bad file — so nothing gets cleaned that cycle. - The outer
Effect.catchCauseprevents a crash but logs a failure and repeats hourly, since the file causing the failure is never removed.
Net effect: Any environment with tool-output files already on disk from before this deploy will have cleanup silently break — likely the common case for upgrading users, not a rare edge case.
Suggested fix: Guard Identifier.timestamp(entry) the same way fs.remove is already wrapped — treat unparseable/legacy filenames as skip-or-delete rather than letting the exception abort the whole pass.
ℹ️ Non-blocking note
packages/schema/src/identifier.ts has the identical 6-byte overflow bug this PR fixes, but it's currently dormant (nothing calls timestamp() on IDs from that code path). Worth knowing about, not required for this PR.
Would you like me to implement the fix for the Truncate.cleanup() guard, or look at anything else in this PR?
Investigated .opencode/plugin/codex-web-search.ts's permission posture
directly. Its codex_web_search tool requests context.ask({ permission:
'websearch', ... }), but the review job's OPENCODE_PERMISSION only
listed edit/external_directory/bash/question/todowrite.
Confirmed empirically (clean env, zero ambient config, CI's exact
policy): any permission category not explicitly listed defaults to
allow, not deny — a tool call requesting 'websearch' proceeded
instantly with no prompt, failing only on missing auth. Also confirmed
the plugin currently fails to load in this same job at all
(OPENCODE_DISABLE_PROJECT_CONFIG=1 blocks its dependency install, as
already documented on this PR), so this is not exploitable today — but
that's incidental, not a permission boundary, and this job has used a
working openai credential before (briefly, earlier on this PR).
Add an explicit 'websearch: deny' so this is closed independent of
whether the unrelated loading gap ever changes. Verified the fix
directly: the same tool call is now blocked at the permission layer
before it reaches the network/auth check, citing the new rule.
There was a problem hiding this comment.
Code Review Summary — PR #48
The PR bundles three independent changes. Two check out cleanly; one has a medium-severity issue worth fixing before merge.
🟡 Medium: id.ts fix breaks retention cleanup for pre-existing files
The core fix (expanding the ID encoding from 48 to 56 bits in packages/hena/src/id/id.ts) is correct — the old buffer was silently truncating now values, and the new encode/decode logic plus tests handle this properly.
The problem: this changes the on-disk ID format, but Truncate.cleanup() in packages/hena/src/tool/truncate.ts:63 decodes timestamps from existing filenames using the new 14-hex-char format. Legacy files written with the old 6-byte encoder will often fail to parse as valid hex (~6/7 chance per file), throwing an uncaught SyntaxError that aborts the entire cleanup pass rather than just skipping that one file.
Why it matters: TRUNCATION_DIR is a persistent, per-user directory with 7-day retention — so any installation with truncated tool output from the past week (a very common upgrade scenario, not an edge case) will have legacy-format files present. Cleanup will silently stop working entirely after upgrade, on every scheduled run, until someone manually clears the directory.
Suggested fix: wrap Identifier.timestamp(entry) (or the loop body) in a try/catch so an undecodable legacy filename is treated as skippable/removable instead of aborting the whole pass.
✅ .opencode/package.json + .gitignore
Matches OpenCode's documented plugin-dependency pattern. No version conflicts with the locally-published packages/plugin.
✅ action.yml
OPENCODE_CONFIG_CONTENT usage is accurate per docs, injected plugin version matches the repo's opencode.jsonc, and websearch permission handling matches documented defaults.
Want me to implement the try/catch fix in truncate.ts for the legacy-ID decode issue?
Reverted the websearch:deny permission from the previous commit — that blocked the tool instead of fixing why it wasn't working. The real blocker: OPENCODE_DISABLE_PROJECT_CONFIG also blocks automatic .opencode/plugin/ discovery, not just .opencode/package.json's dependency install as previously assumed (verified: installing the dependency alone still left the tool unavailable). Fix: OPENCODE_CONFIG_CONTENT can reference a plugin by file:// path, bypassing disabled automatic discovery. Unlike @ex-machina/opencode-anthropic-auth (an external, version-pinned npm package a PR to this repo cannot modify), codex-web-search.ts lives in this repository, so referencing the checkout's own HEAD copy would let a PR get its own edited plugin code executed with this job's credentials while reviewing itself. Fetch it from the PR's base commit instead — the same trust boundary this action previously used for a custom review command loaded from the base commit rather than the PR's copy — then reference that trusted copy explicitly. Verified locally end-to-end (fresh checkout, CI's exact OPENCODE_DISABLE_PROJECT_CONFIG/OPENCODE_PERMISSION, real gh api fetch from an actual base commit): the tool now loads, registers, and gets invoked, failing only on missing openai auth — see follow-up for that remaining piece, which is a separate decision (a new credential reachable by model discretion while processing untrusted PR content).
There was a problem hiding this comment.
Review Summary: PR #48
Scope: Two independent changes — (1) committing .opencode/package.json/.gitignore plus a CI trust-boundary fix in run-opencode/action.yml, and (2) a fix for 48-bit integer overflow in Identifier.create/Identifier.timestamp.
🐛 Medium: ID format change breaks decoding of pre-existing filenames
packages/hena/src/id/id.ts:69-74,80 changes ID encoding from 6 bytes/12 hex chars to 7 bytes/14 hex chars (correctly fixes the overflow, verified by new round-trip tests). However, Truncate.cleanup() in packages/hena/src/tool/truncate.ts:54-66 reads pre-existing filenames from a persistent, non-versioned data directory and calls Identifier.timestamp(entry) on each one.
- Legacy files use the old 12-char format; the new
timestamp()slices 14 chars, so it pulls 2 extra chars from the random base62 suffix as if they were hex. - Only 22/62 base62 chars are valid hex → ~87% of legacy filenames will throw
SyntaxErroronBigInt("0x" + hex). - This throw isn't caught locally (only
fs.removehasEffect.catch), so it aborts the entirecleanup()pass. It's logged and retried hourly, but fails identically every time. - Net effect on any upgraded (non-fresh) install: cleanup silently stops working entirely — reintroducing the unbounded growth problem this PR was meant to fix, via a missing migration path.
Fix suggestion: make per-entry decoding resilient — skip/delete unparseable or legacy-format filenames instead of aborting the whole batch.
Minor: missing test coverage
packages/hena/test/id/id.test.ts tests new-format round-trips but has no test decoding an old 12-hex-char legacy ID — which would have caught the bug above.
Everything else looks solid
- CI action trust-boundary logic (pinning to base SHA, reconstructing
package.jsonfrom trusted version, scoping auth plugin) is internally consistent with no obvious escape. .opencode/package.json/.gitignoreare straightforward version-pin additions.
Want me to fix the Truncate.cleanup() resilience issue (skip/remove unparseable legacy filenames instead of throwing) and add a legacy-format decode test?
Threads OPENAI_OPENCODE_AUTH_JSON through pr-review.yml -> _opencode.yml -> run-opencode action as a new, optional secret, independent of whichever provider REVIEWER_MODEL currently selects (the restored auth.json holds exactly one provider's credential, matching that model, and pr-review currently uses anthropic). First attempt used OPENCODE_AUTH_CONTENT (checked by the plugin's own openCodeAuthEnvironment()) — verified directly that this was wrong: that env var is not scoped to the plugin, OpenCode's own core model resolution reads it too, and it replaces rather than supplements the auth.json file. Setting it to an openai-only credential broke resolving the (unrelated) anthropic reviewer model with the same ProviderModelNotFoundError as anomalyco/opencode#21019, for a completely unrelated reason. Fixed by merging the openai credential into the restored auth.json file instead, so both the reviewer model's own credential and this one are visible via the same unmodified file-based path. Verified end-to-end against the real base commit and a real credential shape: anthropic resolution stays intact and codex_web_search completes an actual search (previously: 'authentication is unavailable'). Also hardens the plugin setup itself: wrap the base-commit fetch + dependency install as one unit in a subshell, so a transient failure (e.g. a registry blip on bun install) degrades to 'codex_web_search unavailable this run' instead of aborting the entire review under set -euo pipefail — this was a real gap in the previous commit, found by the automated review itself running against this exact code.
Found by the automated review of the id.ts commit itself, run twice independently, catching the same issue both times: widening Identifier's encoding from 6 to 7 bytes also widened what Identifier.timestamp() reads from a filename, from 12 to 14 hex characters. Any tool_* file already on disk from before that fix (persistent, XDG data dir, never wiped across upgrades) uses the old 12-hex-char format, and reading 2 extra characters from its random suffix as hex mostly does not parse. That throw was unguarded in Truncate.cleanup()'s loop, so it died before fs.remove ran for that entry (and every entry after it in the same pass) — permanently wedging cleanup on the same file every hourly run, on any upgrade with existing truncation data. Wrap the per-entry Identifier.timestamp(entry) call the same way the adjacent fs.remove already is: treat a filename that fails to parse as eligible for deletion instead of letting it throw. Added a regression test using a deliberately malformed tool_ filename (guaranteed non-hex, not relying on random chance); confirmed it fails without the fix with the exact reported SyntaxError, and passes with it.
There was a problem hiding this comment.
Summary of Review Findings — PR #48
Scope: CI/plugin infra changes (action.yml, _opencode.yml, pr-review.yml), .opencode config, and hena's ID encoding/truncation logic + tests.
🐛 Bug found (moderate severity): packages/hena/src/tool/truncate.ts
id.tswas correctly widened from 6→7 bytes for timestamp encoding (verified bit-shift math and round-trip tests).- However,
truncate.ts's cleanup only catches thrown errors when decoding a timestamp from an ID. An old 6-byte-format ID has roughly a 1-in-8 chance of still parsing "successfully" under the new 7-byte extractor (grabbing 2 extra hex-valid characters from what used to be random suffix bytes) — producing a bogus, often far-future timestamp instead of throwing. - Effect: those entries are treated as not-yet-expired and never get cleaned up — the opposite of the intended behavior.
- Bigger concern: the canonical shared implementation at
packages/schema/src/identifier.tswas not updated with the same widening, and it's actively used byToolOutputStore(packages/core, wired through@hena/server) to write files into the sametool-outputdirectory that hena'struncate.tsscans. So this may not be a one-time legacy-upgrade edge case — it could be an ongoing format mismatch. - Severity: No crash or data corruption — just means some fraction of files silently avoid pruning and accumulate (each capped at 50KB).
- Suggested fix: use filesystem mtime for the retention cutoff instead of decoding a timestamp from the filename —
tool-output-store.ts's owncleanup()already does this and sidesteps the whole compatibility question.
✅ No issues found
- CI/workflow trust-boundary logic (plugin fetched from base commit not HEAD, secrets scoped behind
needs.resolve.outputs.enabled,auth.jsonmerge viajq) — all verified correct. .opencode/.gitignore,.opencode/package.json,id.test.ts— no concerns; test values are appropriate for the new 44-bit timestamp budget.
Would you like me to:
- Post this review as a comment on PR #48 via
gh pr comment, or - Investigate/fix the
truncate.tsvsidentifier.tsmismatch directly, or - Just leave this as informational for now?
Found by the automated review of the previous commit: catching a parse failure only handles filenames that fail to decode. A pre-widening 6-byte-format ID has roughly a 1-in-8 chance of still 'successfully' decoding under the new 7-byte extractor (grabbing 2 extra hex-valid characters from what used to be random suffix bytes), producing a bogus timestamp instead of throwing — and per the review's analysis, that tends toward a bogus *future* timestamp specifically, so the entry looks not-yet-expired and silently never gets cleaned up. More importantly, this was never purely a one-time upgrade artifact: packages/schema/src/identifier.ts is a separate, never-widened implementation of the same encoding scheme, and ToolOutputStore (packages/core/src/tool-output-store.ts) uses it to write into this exact same directory (TRUNCATION_DIR / MANAGED_DIRECTORY both resolve to Global.Path.data/tool-output). So this package's cleanup() needed to agree with whichever encoding actually wrote a given entry, on an ongoing basis, not just tolerate leftover files from before a fix. ToolOutputStore.cleanup() already sidesteps this exact problem by using fs.stat(file).mtime for its retention cutoff instead of decoding anything from the filename. Match that already-correct, already-proven pattern here instead of extending the filename-decoding approach further. Removes the now-unused Identifier import. Rewrote both cleanup tests to set mtime directly via fs.utimes() instead of encoding synthetic ages into filenames (the previous 'unparseable filename' test's premise no longer applies: filename shape is irrelevant to this cleanup now, which is the point). Verified both fail on the prior implementation and pass with this one.
There was a problem hiding this comment.
Review Summary: PR #48
The review covers three bundled changes: .opencode plugin manifest tracking, CI plugin-loading logic in run-opencode/action.yml, and a bug fix for ID timestamp overflow.
1. Medium — bun install trusts a possibly-poisoned node_modules (action.yml:328-339)
The plugin setup re-fetches codex-web-search.ts and regenerates package.json from a trusted source, but never clears node_modules/lockfiles before bun install. Bun skips re-downloading if an existing node_modules/@opencode-ai/plugin already has a matching name/version — it doesn't re-verify the tarball. Since .gitignore doesn't block git add -f, a contributor with push access to this repo (not a fork — those are already blocked upstream) could force-add a malicious package under that name/version and get it loaded with the review job's credentials (auth.json, GH_TOKEN) on the next run. Fix: rm -rf node_modules bun.lock package-lock.json before install, or use bun install --force.
2. Low — auth JSON merge isn't covered by the same failure isolation (action.yml:356-362)
The CODEX_WEB_SEARCH_AUTH_JSON merge runs outside the (set -e; …) 2>/dev/null subshell used elsewhere to keep optional plugin setup from failing the whole job. If that secret is ever malformed, jq -s fails under the outer set -euo pipefail and aborts the entire review run instead of just disabling the plugin. Only triggered by a secret misconfiguration, not attacker input.
3. Verified correct — ID encoding fix + Truncate.cleanup() rewrite
The 6→7 byte widen in id.ts is consistent (offsets and random-suffix length line up). The switch to fs.stat(...).mtime in Truncate.cleanup() matches the existing pattern in tool-output-store.ts and correctly avoids throwing on filenames from the older/other encoding.
No blocking bugs in the core ID fix. The two CI findings are worth addressing before merge, particularly #1 since it undermines the trust-boundary work the PR is otherwise doing.
What this fixes
.opencode/plugin/codex-web-search.tsimports@opencode-ai/pluginat runtime, but nothing declared that dependency for OpenCode's plugin-dependency installer to act on —.opencode/package.jsononly ever existed as an untracked local file, so a fresh checkout (any normal clone) never had it, and the plugin loader couldn't resolve the import..opencode/package.jsondeclaring@opencode-ai/[email protected](matches this repo's pinned CLI version) so OpenCode installs it at startup in any normal checkout..opencode/.gitignore(node_modules,package-lock.json,bun.lock) so the installed artifacts stay out of version control without excluding the manifest itself.Note:
OPENCODE_DISABLE_PROJECT_CONFIG=1(set for everypr-reviewrun as a deliberate security boundary) also excludes.opencode/from dependency installation in that specific job. This fix is correct for any normal local clone; it doesn't by itself install the plugin's dependency insidepr-review/pr-brief— those jobs shouldn't trust PR-supplied plugin code regardless, which is the same reasoning behind the fix below.Why
pr-reviewwas actually failing (separate, pre-existing issue)Root-caused via temporary
--print-logsdiagnostics (added and removed while investigating; final diff has none):Tested exhaustively (isolated
$HOME, no personal config, matching CI's disabled project config): every Anthropic model failed this way, fromclaude-opus-4-5(oldest in the current catalog) throughclaude-sonnet-5(newest) — while a non-Anthropic model resolved and ran instantly in the identical environment. This matches a known, still-open upstream bug: anomalyco/opencode#21019 — "Builtin anthropic provider rejects valid model IDs... opencode rejects it until the model list is updated in a new release."1.18.18(this repo's pin) is the actual currentlateston npm, so there's no newer release to bump to.This repo's own root
opencode.jsonc(pre-existing, unrelated to this PR) already works around that upstream bug locally via@ex-machina/opencode-anthropic-auth, a plugin that authenticates as "Claude Code" to unlock full model access on a genuine Claude subscription.OPENCODE_DISABLE_PROJECT_CONFIG=1correctly excludes that file in CI too, for the same reason it excludes everything else there — so CI's real Claude Max OAuth credential hits the upstream bug with no workaround, for any Anthropic model.Fix
.github/actions/run-opencode/action.yml: inject just that one version-pinned, already-repo-approved plugin viaOPENCODE_CONFIG_CONTENT(config supplied independent of on-disk project config), scoped to when$MODEL's provider isanthropic. This re-enables the specific, already-trusted fix without reopening the checkout itself as a plugin-loading vector — a PR still cannot get its ownopencode.jsonc/.opencode/plugin/*loaded with this job's credentials, and non-Anthropic models load zero extra plugin surface.OPENCODE_PERMISSIONis untouched.Confirmed end-to-end in CI with the required
anthropic/claude-sonnet-5@maxmodel, not just locally: run 32242647032 completed successfully in 6m40s using exactly that model and posted a real review to this PR — which is how the provider-scoping feedback below was caught and then addressed in a follow-up commit.Also fixed: deterministic (not flaky) test failure
CI's
unit (linux, shard 1/2)job was failing onpackages/hena/test/tool/truncation.test.ts:260— reproduced 100% of the time, including in complete isolation (single test file, 3/3 local runs).Root cause:
Identifier.create(packages/hena/src/id/id.ts) shifts the millisecond timestamp left 12 bits to make room for a per-millisecond counter, but only allocated 6 bytes (48 bits) to store the result. Any real-world date past ~1972 needs more than 48 bits once shifted, so the encoding silently overflowed — e.g. a 2026 timestamp round-tripped throughIdentifier.timestamp()decoded back to 1970. This went unnoticed everywhere else because ascending IDs are mostly compared to each other for ordering, and nearby real-time values still sort consistently after wrapping.Truncate.cleanup()is the one caller that decodes an absolute timestamp for a multi-day retention comparison, andnowcurrently sits within the ~10-day window where the 48-bit wraparound crosses between the cutoff and a file that should be kept. This recurs for ~10 days every ~2.18 years (2^36 ms) as real time crosses each wrap boundary — a live, deterministic bug, not test flakiness.Fix: widen the encoding to 7 bytes (56 bits) — enough for a 44-bit timestamp (safe past year 2500) plus the 12-bit counter. Total ID length is unchanged. Added
test/id/id.test.tsto lock in the round-trip (verified it fails without the fix, on the exact timestamps that broketruncation.test.ts).All CI checks are now green:
unit (linux, shard 1/2)now passes, along with every other check.