Skip to content

test: e2e native lane for real opencode (v1+v2) vs deterministic fake upstream (#1267) - #1272

Merged
ranxianglei merged 1 commit into
masterfrom
2026-09-24_e2e-opencode-native-lane
Sep 26, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-09-24_e2e-opencode-native-lane

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

The opencode lane of the native-client e2e family (#1239, skeleton from #1246's pi lane): a REAL opencode host driven headless (opencode run) with bili's real self-spawned plugin (dist/agent/opencode-native.js) against the deterministic fake chat upstream — zero tokens — asserting all four #1239 acceptance items:

#1239 item Test
1. interception + plugin-mode claim T1: every oracle row carries plugin: "opencode" + one ses_* conversation; requests reach the fake only through the proxy
2. session binding + status reachable T3: live proxy answers ok at GET /__bili/plugin/status?conversationId=<ses> for the bound session (+ persisted metadata.pluginAgent === "opencode" asserted in T1/T2)
3. acp_status host-registered, callable, returns T1: ACP tools present in the model request's tools[]; the tool result is re-sent in history and matches the kernel report shape (both v1/v2 surfaces)
4. compress really executes + folds T2: model-invoked compress folds run-one filler into a persisted block ([Compressed m… → N block(s), ~T tokens saved.], ≥1 block on disk after graceful stop); carrier = tool call+result pair in the follow-up history

Design notes

  • Reuses tests/e2e/fake-upstream-chat.mjs from native pi e2e (#1239) + fix one-shot stamp race (#1243) #1246 with three ADDITIVE capabilities the opencode lane needs: a title-call guard (opencode's side-channel title generation shares the directive queue key with the main loop), balanced-brace directive JSON (请调用compress {"content":[…]}), and a lastUserRef oracle field so the suite pins an exact fold target instead of guessing among example tags embedded in kernel prompt text.
  • The /acp slash command is TUI-only and unreachable under opencode run, so item 2 is asserted through the same backend endpoint the command panel consumes (documented in-test).
  • Kernel protected-zone root cause documented in-test: with defaults (preserveRecentTokens: 5000) a small synthetic session is entirely inside the protected zone and no explicit range can fold; the suite pins {"compress":{"preserveRecentTokens":0}} in the hermetic $XDG_CONFIG_HOME/billion-context/billion-context.json — test-local config, not a shipped default change.
  • v2 quirk handled: run rides a shared managed service on a fixed channel-derived port; the suite pins service.json to a unique free port per context (v1 ignores it).

Behavior flags (per deliverables policy)

  • Shared-fake changes are additive only; pi prompts never match title patterns and brace-less directives parse identically ⇒ pi lane unaffected — re-ran its full native e2e against this diff: 4/4 pass.
  • No wire-protocol, config-schema, or version changes; no shipped default changes.

Pre-flight (rebased onto master 8e5eb58)

  • typecheck ✅ · build ✅ (incl. new dist-import-annotations gate) · full test suite 2501 tests, 0 fail, 9 skip (gated e2e) ✅
  • Lane runs (real binaries, zero tokens):
    • V1: opencode 1.14.46 — 4/4 pass (~150s)
    • V2: opencode 2.0.3 (@opencode/cli) — 4/4 pass (~30s)
    • pi (shared-fake regression check) — 4/4 pass
  • CI: new .github/workflows/ci-e2e-native-opencode.yml mirrors ci-e2e-native.yml (PR trigger + dispatch, zero tokens), pinned @opencode/cli@2.0.3; the issue requires at least one fully-green lane in CI, V1 additionally verified locally above.

Fixes #1267

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-24_e2e-opencode-native-lane (f296268)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1272

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

Option B — Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Reviewing PR #1272 (opencode native e2e lane, fixes #1267).

Initial checks done:

  • Branch is fully up-to-date with live master — base = current tip 8e5eb582 (PR-base is an ancestor with 0 commits after it on master), so no stale-base/rebase concern.
  • Diff is scoped to 4 files / +913 −10: new tests/e2e/e2e-native-opencode.test.ts (747 lines), new .github/workflows/ci-e2e-native-opencode.yml, a tests/e2e/README.md section, and 3 additive changes to the shared tests/e2e/fake-upstream-chat.mjs (title-call guard, balanced-brace directive JSON, lastUserRef oracle field).
  • The new CI workflow is a faithful mirror of the pi lane's ci-e2e-native.yml (concurrency group, pinned CLI with rationale, E2E_OC_BIN, ACP_TEST_E2E_OC_NATIVE=1 gate, artifact collection from tmp/e2e-native-opencode-* — which matches where the test writes).
  • Asserted result strings are byte-identical to the already-green pi lane, so they're real kernel/proxy output, not aspirational.

Now running local verification (typecheck + build + full unit suite, then the real opencode and pi lanes end-to-end) before giving a verdict. Will follow up with the full review.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Full review of PR #1272 complete. I checked out the branch (d3b55b87, base = live master tip 8e5eb582, so up-to-date, no rebase needed), read all four files, and re-ran the verification myself rather than trusting the pre-flight notes. Verdict: mergeable (human merges — I won't).

① Direction (original issue #1267)

Correct and on-target. #1267 asked for an opencode native e2e lane reusing #1246's pi skeleton, asserting #1239's four acceptance items, gated env, CI mirror, ≥1 green lane. This delivers exactly that and exceeds the floor: both V1 and V2 lanes are green (not just one). It addresses the root goal (real-client coverage for a lane that previously had none) — not a symptom.

② Regression review (existing behaviors on touched paths)

Touched surface is tests/e2e/fake-upstream-chat.mjs (shared), one new test, one new workflow, one README section. I inventoried the existing behavior each carries and its conclusion:

  • parseDirectives regex rewrite (flat→balanced-brace): backward-compatible. Brace-less directives parse identically; nested-brace JSON was previously un-parseable (that's the additive capability). Verified empirically — see below. No regression.
  • Title-call guard (isTitleCall → inert "e2e-title"): additive, returns before touching queues. pi prompts never match /title generator/i or ^generate a title\b. No regression.
  • lastUserRef oracle field: purely additive JSONL column; existing consumers ignore unknown fields. No regression.
  • Shared-fake impact on the pi lane: this is the one real risk, so I ran it (see ⑥). Confirmed unaffected.
  • No production/wire/config/version/default changes. The diff touches only tests/ + .github/workflows/ + README.md. preserveRecentTokens:0 lives in a hermetic $XDG_CONFIG_HOME/billion-context/billion-context.json written inside the test's throwaway dir — a test-local config, not a shipped default change. No behavior drift anywhere.

③ Code review

High quality, mirrors the proven pi lane's discipline:

④ Test validity

Real teeth, not tautologies — it drives real opencode through the real self-spawned plugin + real proxy against a deterministic fake, then asserts observable outcomes: every request plugin-stamped with one ses_* conv; ACP tools present in tools[]; acp_status result matches the kernel report shape and carries the bili version stamp; compress actually folds (result reports [Compressed m… → N block(s), ~T tokens saved.]); the plugin-mode carrier (tool call+result pair) rides in follow-up history (roles includes tool); proxy logs tool compress executed via plugin; ≥1 block persisted after graceful stop; live /__bili/plugin/status answers ok:true. If interception, tool registration, or compression regressed, these fail. The asserted result strings are byte-identical to the already-green pi lane, confirming they're genuine kernel/proxy output.

⑤ Diff cleanliness

4 files, +913/−10, every line purpose-related. No whitespace churn, no lockfile/generated churn, no unrelated files. Clean.

⑥ Verification evidence (run by me on the PR branch, not taken on faith)

Check Result
npm run typecheck ✅ clean
npm run build ✅ dist-import-annotations: OK, opencode-native.js produced
Full unit suite ✅ 2501 pass / 0 fail / 9 skip (matches the stated pre-flight exactly)
Real opencode V1 lane (opencode 1.14.46) ✅ 4/4 (preflight + T1 acp_status + T2 compress-fold + T3 status endpoint)
Real pi lane (pi 0.83.6) — shared-fake regression ✅ 4/4
GitHub CI on d3b55b87 ✅ all 10 checks green — incl. the new V2 opencode lane (@opencode/cli@2.0.3) and the pi lane, plus the ubuntu/windows × node 22/24 matrix, build-artifact, version-guard

So both opencode generations are confirmed (V1 by my local run, V2 by CI), the pi lane is confirmed non-regressed in both local and CI, and the whole matrix is green. The only thing standing between this and merged is the human review/merge gate (mergeable_state: blocked is "needs approval", not a failed check).

Minor observations (non-blocking)

中文摘要:为 opencode 宿主补上了与 pi lane 对等的原生 E2E lane(真客户端 + 真自生插件 vs 确定性假上游,零 token),四项验收全部以真执行断言;我独立复跑了 typecheck/build/全量单测(2501 过)以及真 opencode V1 与真 pi 两条 lane(各 4/4),GitHub CI 亦全绿(含新 V2 lane),共享 fake 改动确认无回归、无生产行为漂移——可以合并(由人来 merge)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

Independent deep review complete — and executed for real, locally: rebased onto current master (README docs conflict resolved by union, head 58f1b6c), built, then ran the full suite against the real opencode 1.14.47 binary with the deterministic fake upstream (zero tokens):

✔ preflight (E2E_CHECK)
✔ one-shot: intercepted, plugin-stamped, ACP tools registered, acp_status executes  (27s)
✔ compress: model-invoked compress really folds context                              (41s)
✔ status endpoint: live proxy answers for the bound conversation                    (22s)
pass 4 / fail 0

Verified sound:

  • Oracle strength: assertions run against EVERY forwarded row (plugin stamp incl. the title side-channel, ses_ session continuity across runs, ACP tool set presence on model requests, tool-result re-sent in follow-up history = plugin-mode carrier).
  • v1/v2 split done right: ocVersion major → 1.x rides the bare-dist V1 .server() lane (zod interop), 2.x uses V2 setup + managed-service pin + recorded-pid teardown (run otherwise rides a shared serve --service).
  • Isolation: cleanEnv, tmp WORK_ROOT, graceful proxy stop + awaitProxyExit, managed-service kill in teardown.
  • Gating follows repo rules: ACP_TEST_E2E_OC_NATIVE=1 (default skip keeps npm test free); E2E_CHECK=1 zero-token preflight; CI workflow pinned like pi/codex ([e2e] fake-upstream overflow 测试与仓库 AGENTS.md 体积隐性耦合:AGENTS.md 增长即破坏 CI(#803 触发) #815) with concurrency-cancel + 15min timeout.
  • Fold assertions match the format contract exactly ([Compressed m\d+–m\d+ → \d+ block(s), ~\d+ tokens saved.]), plus the persisted-session side (blocks on disk) — not just the wire.

Gates on the rebased head: typecheck ✓ / build ✓ / suite 4/4 real-binary ✓. Ready to merge when CI is green.

… upstream (#1267)

Real opencode host (1.x bare-file plugin / 2.x wrapper-dir plugin) driven
headless through bili's self-spawned proxy against the deterministic fake
chat upstream; zero tokens. Asserts the four #1239 acceptance items:
interception + plugin-mode claim on every request, ACP tool registration
and acp_status round-trip, model-invoked compress really folding a block
(persisted after graceful stop), and the live status endpoint answering
ok for the bound conversation (/acp analog — the slash command is
TUI-only and unreachable in run mode).

Gated behind ACP_TEST_E2E_OC_NATIVE=1 (skip by default); E2E_CHECK=1
zero-cost preflight. CI workflow pins @opencode/cli@2.0.3.
@ranxianglei
ranxianglei force-pushed the 2026-09-24_e2e-opencode-native-lane branch from 58f1b6c to f296268 Compare September 25, 2026 15:38
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Follow-up after your rebase — I tracked the branch through both force-pushes and re-verified against the actual current-master target, not the head your report referenced. Verdict unchanged: mergeable (human merges).

What changed while I was reviewing

The branch moved d3b55b87 → 58f1b6ce → f296268f. Final head f296268f is rebased onto current master d3c8af84 and mergeable_state is now clean (was behind). The three functional files (e2e-native-opencode.test.ts, ci-e2e-native-opencode.yml, fake-upstream-chat.mjs) are byte-identical across all three heads — so my round-1 code review carries over verbatim; only tests/e2e/README.md changed between heads.

The one gap I closed: your run predated #1335

Your report references head 58f1b6ce, whose parent is 840742d2 — i.e. before #1335 ("native-hook attach gate — refuse lifecycle-less proxies") and #1338 landed. Since the PR merges into a master that does have those, I reproduced the exact merge result locally (origin/master d3c8af84 + the PR, no conflict) and ran the gates there:

Check (on d3c8af84 + PR, incl. #1335) Result
typecheck ✅ clean
build (dist-import-annotations) ✅ OK, opencode-native.js produced
full unit suite ✅ 2646 pass / 0 fail / 11 skip (up from 2501 — master added ~145 tests since my first pass)
real opencode V1 lane (opencode 1.14.46) ✅ 4/4
real pi lane (shared-fake regression) ✅ 4/4

Why #1335 is safe here (reasoning + empirical): #1335 gates ensureProxyRunning/pickAttachable to attach only to a proxy whose health endpoint reports watchdog.armed == true, else spawn its own. This e2e is hermetic and relies purely on the plugin self-spawn (no pre-started bili start; ports via freePort()/listen(0)), so there is no lifecycle-less listener to refuse — and an armed self-spawned proxy stays shareable per #1335's own "Preserved: armed instances stay shared" note. The 4/4 run confirms it empirically rather than trusting that inference.

README union scar — spotted & already fixed

During the pass I found the intermediate head 58f1b6ce had a botched union at the pi→opencode seam in tests/e2e/README.md: a duplicated the codex pin (#815). sandwiched between two stray --- rules. Your final head f296268f resolves it cleanly (single --- divider, consistent with the file's other section breaks) — I verified the raw bytes. No action needed from me.

Notes

  • I ran the V1 lane locally (only opencode 1.14.46 present here); the V2 lane is exercised by the pinned CI workflow (@opencode/cli@2.0.3). Functional files are unchanged from round 1 where that CI lane was already green, so V2 is covered by CI on this head.
  • No wire/config/version/default changes; diff is test+workflow+docs only.

中文摘要:PR 已 rebase 到最新 master(含 #1335 attach 门禁)且可干净合并;我在「当前 master + 本 PR」的合并目标树上独立复跑了 typecheck / build / 全量单测(2646 过)/ 真 opencode V1(4/4)/ 真 pi(4/4),全绿——关键是你报告引用的头在 #1335 之前,我补验了含 #1335 的目标树确认附着门禁不影响这条 hermetic 自生代理 lane;顺带发现的 README union 重复行已在你的最终头里干净修掉。可以合并(由人来 merge)。

@ranxianglei
ranxianglei merged commit 9b3d1c4 into master Sep 26, 2026
12 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-24_e2e-opencode-native-lane branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] E2E native lane: real opencode + bili plugin vs deterministic fake upstream (from #1239)

1 participant