Skip to content

fix: opencode pinned plugin entry + lane self-update by re-pin (#1108, revives #1143) - #1354

Closed
ranxianglei wants to merge 4 commits into
masterfrom
2026-09-22_opencode-pinned-entry
Closed

ranxianglei wants to merge 4 commits into
masterfrom
2026-09-22_opencode-pinned-entry

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Revives closed PR #1143 (same branch, rebased; GitHub refuses to reopen a PR after its branch is force-pushed). Fixes #1108.

What (unchanged from #1143's reviewed design)

  1. bili plugin install opencode writes the plugin entry as an EXACT version (billion-context@0.1.x) instead of the bare spec — every boot resolves from local cache; the bare spec re-resolves @latest at boot, which is the [opencode 2.x] bare npm spec ("billion-context") triggers managed-service restart loop; pinning an exact version avoids it #1108 restart-loop trigger on opencode 2.x.
  2. The opencode lane self-updates without writing its own copy (native模式下自动更新问题需要解决 #991): the update check's host-managed refusal branch (managed.owner === "opencode") re-pins the config entry to the newest registry version via repinOpencodeLaneIfNewer — opencode's own manager fetches that version at next boot, from local cache afterwards.

New in this revival

The gate the maintainer set in #1143's hold note — the #1153 hermetic local-registry harness landed via #1161, so the demanded e2e regression now exists (commit 8f22724, tests/e2e/e2e-registry.test.ts):

  • publish old + new versions to the local verdaccio, then on the REAL chain:
  • Red-on-master verified for the two behavior subtests (bare-entry + no-re-pin semantics fail them); all 6 subtests green on this head (ACP_TEST_REGISTRY=1).

Rebase notes: src/update.ts conflict vs master's #1196 dsh-lane refresh resolved as a union (opencode re-pin + dsh refresh both inside the refusal branch, guarded managed && installDir).

Unit tests: tests/plugin-install-opencode.test.ts + tests/update-opencode-repin.test.ts 28/28 green, typecheck clean.

Merging is a human decision per AGENTS.md.

ework-agent and others added 4 commits September 25, 2026 23:53
…rom local cache (#1108)

A bare npm spec makes opencode's managed plugin service re-resolve @latest
against the npm registry at every boot; on slow networks that pushes cold
start past the health-check window and the supervisor respawn-loops. Write
"billion-context@<self-version>" instead (bare-name fallback when the
version is unknown), recognize both forms everywhere the entry is matched,
and have the update lane report stale pins instead of the generic
opencode-managed hint.
#1108)

Install pins the installing bili's version (sync, offline — equals npm
latest in the normal just-installed flow); `bili plugin update opencode`
now resolves the newest registry version and re-pins the entry in place
(only the entry string — the opencode-managed package copy stays
opencode's, #991). Foreign entries preserved verbatim (#1002).
… check (#1108)

The spawned proxy runs startAutoUpdate like any install; its checkForUpdate
currently early-returns for host-managed copies without even looking at the
registry, so a pinned entry would freeze the opencode lane forever. In the
refusal branch (owner opencode) resolve the newest registry version and
re-pin the config entry instead — opencode's own manager fetches that
version at next boot, from local cache afterwards. The copy itself stays
opencode's (#991); the hook lives entirely inside the refusal branch and
never touches the check/download/extract/install path, and every failure is
caught and logged.
…in self-update (#1108)

The gate the maintainer asked for on PR #1143: publish old/new versions to
the local verdaccio, then verify on the real chain that (a) plugin install
writes the exact-version entry (and is idempotent), (b) an opencode-managed
old copy's update check re-pins the entry instead of writing itself, and
(c) the exact spec resolves from local cache with --offline, byte-identical
to the registry tarball. Replaces the TODO(#1143) master-semantics
assertions.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-22_opencode-pinned-entry (8f22724)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1354

Each push to this PR publishes a new version under the pr-1354 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1354.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

[bot] 🏷 Closing this as an exact duplicate of #1363 — same fix, same tree, same base.

Duplicate screening (per AGENTS.md)

Review verdict (applies equally to #1363 — identical content)

Verified on this head: typecheck clean; full suite 2643 pass / 0 fail / 11 skipped (gated e2e); build OK; targeted opencode tests 23/23; CI 11/11 green. Code review finds no regressions: the auto re-pin lives inside the host-managed refusal branch, never throws, never downgrades, and never writes the opencode-owned copy (#991 intact). Tests have real teeth on every changed behavior, including negative cases (dev-checkout refusal, unknown version, scoped-lookalike rejection, fetch failure) and the real verdaccio chain proving the copy stays byte-untouched while the entry re-pins.

Release note for the human: this touches src/update.ts, so per AGENTS.md §5/§7.4 it stays human-merge, and the no-op validation release should ship first (version-bump-only release, confirm installed copies self-update through it), then merge #1363 and release.

Merging remains a human decision either way.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Reviewed this PR (agent work — verified, did not redo it) and found it is an exact duplicate of #1363. Action taken: commented on #1354, closed it, and tagged both items 重复. The canonical revival to review/merge is #1363 (byte-identical tree, same base d3c8af84 = current master, already announced in the #1108 thread).

Duplicate screening

Review verdict (applies equally to #1363)

Verified on head 8f22724a locally and via CI:

  • Gates: typecheck clean · full suite 2643 pass / 0 fail / 11 skipped (gated e2e) · build OK · targeted opencode unit tests 23/23 · CI 11/11 green (incl. hermetic verdaccio e2e, real-codex E2E, build-artifact).
  • Direction (①): correct layering per [opencode 2.x] bare npm spec ("billion-context") triggers managed-service restart loop; pinning an exact version avoids it #1108's own analysis — the root cause lives in opencode (fixed managed-service port inside the ephemeral range + uncapped respawn); bili cannot fix that, and pinning the entry to an exact version removes bili's side of the trigger (per-boot @latest re-resolution). In-scope part fixed at the source (installer + update lane), not masked in transit. ✓
  • Regression audit (②): existing behaviors touched, each accounted for:
    • installer entry form: bare billion-context → exact billion-context@<v> (behavior change, disclosed below); legacy bare entries migrate on next install/update; dev-shim form untouched;
    • opencode-managed copy update: previously frozen until manual reinstall → now auto re-pin each check cycle (disclosed below); refusal log line unchanged; on-disk copy never written (native模式下自动更新问题需要解决 #991 intact — e2e asserts byte-untouched at old version);
    • checkForUpdate global self-update path and the dsh plugin-market installs never auto-update: the refresh chain's only trigger is a global bili self-update #1196 dsh-refresh path: untouched — the new block sits inside the managed && installDir refusal branch, gated managed.owner === "opencode", wrapped so it never throws;
    • remove/status now recognize pinned entries (isOpencodeNpmEntry) — required, otherwise a pinned entry would survive plugin remove as a foreign string; scoped lookalikes still rejected.
      No unintended regressions found.
  • Code (③): sound. One non-blocking observation: in the manual bili plugin update opencode path, when the registry lookup fails it falls back to selfVersion() — if a local bili were somehow older than an existing pin, that could downgrade the pin (needs registry outage + stale local + newer pin; the auto path correctly guards with isVersionNewer only). Not worth holding the PR.
  • Tests (④): real teeth. Unit tests pin every new semantic including negatives (dev-checkout refuses to re-pin, unknown/0.0.0 version falls back bare, fetch failure warns without throwing, stale-pin collapse keeps position and foreign entries). The e2e subtests run the real chain against local verdaccio: pinned write + idempotent re-run, managed-copy refusal with byte-identical old tarball on disk while the config re-pins, and npm pack --offline proving the boot-locality mechanism (byte-identical cached tarball, zero registry round-trips). Red-on-master verified by the author for the two behavior subtests.
  • Diff cleanliness (⑤): 5 files, every line serves the purpose; no churn, no lockfile noise. Clean.

Behavior changes (old → new, per reporting policy)

  1. bili plugin install opencode writes billion-context@<exact version> instead of the bare package name — so every boot resolves from npm's local cache instead of re-resolving @latest (the [opencode 2.x] bare npm spec ("billion-context") triggers managed-service restart loop; pinning an exact version avoids it #1108 restart-loop trigger). Existing users' bare entries are migrated on their next install/update.
  2. An opencode-managed bili copy now self-updates automatically: each update check (~3 min) re-pins the config entry to the newest registry version (only when newer), which opencode's own manager then fetches at next boot. Previously such copies were frozen until a manual reinstall.
  3. Consequence: opencode-managed copies make one registry dist-tag lookup per check cycle (previously zero background traffic from bili). Benign — it cannot reintroduce the [opencode 2.x] bare npm spec ("billion-context") triggers managed-service restart loop; pinning an exact version avoids it #1108 loop, which lived in opencode's boot-time reconciliation, not bili's checker.

Release gate (human decision)

Per AGENTS.md §5/§7.4 this must stay human-merge — it touches src/update.ts, so ship a no-op validation release first (version-bump-only, confirm installed copies self-update through it), then merge #1363 and release. Merging is yours to do: #1363

中文摘要:#1354 与 #1363 是同一修复的字节级相同重复项,已按规则关闭 #1354 并打「重复」标签;内容本身审查通过(方向、回归、代码、测试、diff 均无问题),可走发布流程——先出 no-op 验证版再合并 #1363(人工合并)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[opencode 2.x] bare npm spec ("billion-context") triggers managed-service restart loop; pinning an exact version avoids it

1 participant