33 Commits
Author SHA1 Message Date
ranxianglei 28f11a09eb fix(gate): agentsR example default, fresh rc files, README knob parity (PR#6938 review)
- config.example.json shipped agentsR='' (present-but-empty), which the
  jget/:-/|| chain treats as unset-inherited from GATE_AGENTS — Lane R
  would run the full P agent set, hit 'unsupported lane' and false-red
  after paying for six agents of real-model turns. Example now ships the
  launcher default dsh,pi, matching _doc_agentsR.
- entrypoint.sh: rm the per-run rc files before launching the concurrent
  subshells — a stale .rc-plugins/.rc-restart in a persistent outDir
  could be read back if the subshell died before its final echo, a
  failure direction that HIDEs a red in release verification.
- both READMEs: the dsh-variants opt-in sentence still listed dsh-google
  (now in the default set), and laneScript/snapshotRender were missing
  from the config-key lists (they only had _doc_* in the example).
2026-11-16 20:32:17 +08:00
ework-agent aa92494115 fix(gate): t1 prompt quoted the corpus line count dynamically
buildCorpus() produces a 441-line file, but the t1 recipe said "~1300
lines". Most models ignored the mismatch; opencode/codex occasionally
flagged it ("the file is only 441 lines, but the task says ~1300") and
wasted the turn, red-ing S40/S07 t1 (2026-11-16 gate run 4). Quote the
actual count instead.
2026-11-16 18:23:41 +08:00
ework-agent 850f0adf08 fix(gate): snapshotRender knob via config tier — env tier never reaches lane proxies
cleanEnv() strips BILI_* from the lane spawn env by design, so
BILI_ROLLOUT_SNAPSHOT_RENDER set container-wide still resolved to
off(bucket) in every lane (verified in the #6785 gate run: rollout line
showed snapshotRender=off(bucket, 7206/10000 vs 0bp) with the env set).
The knob now writes rollout.features.snapshotRender=true into the P/R
lane bili.json — the config tier the rollout resolver honors above
bucketing. GATE_SNAPSHOT_RENDER stays harness-internal; the proxy never
sees it.
2026-11-16 17:01:59 +08:00
ework-agent 772af00a4f feat(gate): laneScript + snapshotRender config knobs
The snapBase storage substrate reaches the R lanes via the bundled
restart-lanes.mjs, but the P lanes prefer the candidate checkout OWN
plugin-lanes.mjs — which predates the GATE_SNAPBASE knob, so P ran
off-state in candidate-branch verification. laneScript forces the
bundled copy (the entrypoint already supports GATE_LANE_SCRIPT for
exactly this). snapshotRender flips BILI_ROLLOUT_SNAPSHOT_RENDER
(env tier > 0% rollout) so the egress BODY plane renders live —
without it storage.snapBase only exercises the v2 substrate, not the
body path the verification is actually after. Both keys documented in
config.example.json.
2026-11-16 16:59:38 +08:00
ci-check f68f0813bf docs(gate): document the snapBase config key (promised in the PR body)
config.example.json gains the key with a _doc_snapBase line; README en/zh
config-key lists gain the entry: P/R lanes only, "all" or protocol
cohort subset, absent/off = byte-identical gate.
2026-11-16 14:13:13 +08:00
ci-check 58fa063368 refactor(gate): one gateStorageCfg — export from plugin-lanes, import in restart-lanes
The 8-line GATE_SNAPBASE mapping was copy-pasted into both lane scripts.
restart-lanes.mjs already imports buildCorpus/CODEWORDS from
plugin-lanes.mjs, so the function now lives in one place (exported) and
is imported — same knob, same bili.json surface, no second copy to drift.
2026-11-16 14:13:13 +08:00
ci-check 977985d2c7 fix(gate): GATE_SNAPBASE was dead — RUN+= before the RUN=(...) init gets wiped by the reassignment
The snapBase env append landed in the config-parse block, but RUN is
(re)initialized with 'RUN=(docker run --rm ...)' further down, which
replaces the whole array — so GATE_SNAPBASE never reached the container
and the switch could never turn the plane on. Move the append to right
after the RUN init, alongside the other -e flags.

Verified via --dry-run: with snapBase set the docker command now carries
GATE_SNAPBASE (all / subset values); without it, nothing changes.
2026-11-16 14:13:13 +08:00
ework-agent 48980eb543 feat(gate): GATE_SNAPBASE knob — run P/R lanes with the candidate's snapBase egress plane
Config key "snapBase" on bili-gate.sh --config ("all" = every protocol
cohort, or a comma list of openai,responses,anthropic,google) sets
GATE_SNAPBASE in the container; plugin-lanes and restart-lanes then add
storage.snapBase to the bili.json every lane proxy reads. Unset/off keeps
the gate byte-identical (plane default-off). Needed to validate #6785's
egress snapshot plane end-to-end against real clients.
2026-11-16 13:52:29 +08:00
ework-agent 764ab5a9bd fix(gate): claude R-lane window keys must match the client's model ids
bili's window lookup is keyed by the model id the CLIENT requests
(resolveModelEntry in src/server/handle.ts). The claude lane's bili.json
map only carried the upstream MODEL1 ids, so claude-code's own ids
(claude-sonnet-4-5-*/claude-haiku-4-5-*) missed it: configured=none,
source=registry-peek 200k, the small window never applied and every fold
assertion ran against raw history (2026-11-15 clauder validation run:
15/18, the 3 reds were all 'no fold fired').

Harvest the real ids from the [window] log lines before each window
rewrite (same mechanism as plugin-lanes' harvestWireModels), so both
claude's main and background model ids carry the gate window.
2026-11-16 13:39:55 +08:00
ci-check f69e0addd2 docs(gate): sync restart-lanes header protocol doc with the claude lane (PR #6823)
The claude (anthropic-wire) lane landed in this PR but the file-header
protocol block still read "dsh headless, pi" / "Per agent (dsh, pi)" and
claimed the hostile mid-turn variant runs per agent (it is dsh-only in code).
Header now names claude, notes its R0/R1-only harness-re-established matrix,
and the GATE_R_CONC comment drops the stale "both agents" phrasing.
Comments only — no behavior change.
2026-11-15 20:34:00 +08:00
ework-agent da2db8cf66 fix(gate): import-guard plugin-lanes main() — stop restart-lanes double-running the P suite
restart-lanes.mjs imports { buildCorpus, CODEWORDS } from plugin-lanes.mjs;
the unguarded top-level main() re-ran the whole P-lane suite inside the
restart-lanes process (GATE_AGENTS there = dsh,pi), in the SAME $WORK lane
dirs: two npm -g installs into one prefix -> ENOTEMPTY, a sibling pi
recorder killed via the shared instance registry (503 connect-refused on
pi t2-t4), and the side-effect suite's process.exit(1) became the R
process's exit code. Every containerized gate run since the in-repo move
was contaminated; the 2026-11-15 concurrent verification run's wall time
(39.5min) included doubled model load in the R phase.
2026-11-15 20:23:15 +08:00
ework-agent 732d957518 feat(gate): anthropic-wire restart lane (claude) + dsh-google in default matrix
Coverage follow-up (PR#6793 review, owner asked: 协议是否齐全/场景/客户端):

1) Lane R gains a claude agent (opt-in via agentsR): the first non-openai
   CLIENT-SIDE wire through the deep restart scenario. Prefix topology —
   claude-code speaks anthropic over HTTP to a harness-managed bili proxy
   child (-> recorder -> model); the small window is bili-side (provider
   context + proxy restart, prefix-lane rule) at 32768 (claude's
   unfoldable floor sits near the wall — Lane P lesson). Kill matrix:
   the proxy is killed via SIGTERM/SIGKILL and re-established on the SAME
   port by the harness (nothing auto-respawns a manually started proxy);
   each respawn must resume the session, outbound stays compact AND
   non-empty, exactly one live proxy (no split-brain). Every turn also
   gets the 600s budget (claude small-window preflight is a multi-stage
   distillation; the 300s budget SIGTERMs mid-preflight — Lane P lesson).

2) dsh-google joins the default Lane P matrix: the google-generative-ai
   client door now runs in every gate (the harness lane + wire assertions
   already existed; it just was never in the default set).

Also: restart-lanes setHostWindow is now async (the claude window flip
restarts the proxy and must complete before the next turn); the claude
proxy handle is hoisted to lane scope so teardown always reaps it; stale
duplicate comment removed.
2026-11-15 20:13:00 +08:00
ework-agent 2c6c51ef38 fix(gate): default restart-lane agents to dsh,pi in the launcher
Without an agentsR key in the local config the launcher exported
GATE_AGENTS_R="" — and the entrypoint's
${GATE_AGENTS_R:-${GATE_AGENTS:-dsh,pi}} fallback then fed the FULL
plugin-lane agent list (5 agents) into restart-lanes, which only
supports dsh and pi ("unsupported lane" reds). Default it to dsh,pi.
2026-11-15 19:29:56 +08:00
ci-check db25b22737 fix(gate): pass concurrency knobs through bili-gate.sh + document them
The PR's GATE_CONCURRENT / GATE_P_CONC / GATE_R_CONC are read inside the
container but were never passed through by the host launcher, so the
documented GATE_CONCURRENT=0 escape hatch (pristine cache isolation to
re-check a false-red R cache-recovery assertion under concurrency) was
unreachable via the standard bili-gate.sh path. Pass the three vars straight
into the container with the same defaults the entrypoint / lane scripts
already use (no default-behavior change), and document them in the gate
README (en + zh).

Review fix for #6810.
2026-11-15 18:17:16 +08:00
ework-agent 57e75a9b94 perf(gate): run plugin (P) + restart (R) lanes concurrently
The gate ran everything serially (~45-50 min wall), but the shared
upstream (sglang / relay) comfortably takes ~6 concurrent consumers and
the lanes are fully independent: per-lane recorder ports, per-lane XDG
dirs, per-agent BILI_ZONE_PORT ladders (restart lanes already hash with
a distinct prefix).

- plugin-lanes: agents now run through a worker pool (GATE_P_CONC,
  default 4) instead of a serial for-loop.
- restart-lanes: same (GATE_R_CONC, default 2 = both agents at once).
- entrypoint: sections 5.5 (P) and 5.7 (R) launch side by side and wait
  on both; their internal pools keep total in-flight model consumers at
  ~6. Lane I/X still runs after: its publish flips the in-container
  registry's latest tag, which must not race the P/R lanes' update
  probes (Lane U's assertion already ran in section 5).
- GATE_CONCURRENT=0 restores the legacy serial order for
  measurement-sensitive runs (cache-isolation fallback).
- per-lane recorder handle map replaces the process-global activeRec.
2026-11-15 17:51:57 +08:00
ework-agent 22f5e1bb1a fix(gate): readable evidence after run + one retry on the R-lane small-window turn
- entrypoint: chown /work to GATE_UID:GATE_GID at the end (bili-gate.sh
  passes the invoking user) — lane logs/sessions were root-owned 0600 and
  unreadable on the host, which blocked post-run diagnosis (2026-11-15)
- restart-lanes t3: one retry before the post-fold bound check. The client's
  (dsh/pi-ai) proactive overflow fold is estimated-tokens based and wobbles:
  measured same fixture fold-fires on one run, raw send + client-side
  CONTEXT_WINDOW_EXCEEDED on the next (also the 11-03 signature). bili's
  engine folds correctly whenever the client asks (99% shrink in the green
  run); the retry mirrors the existing t2 needle-retry policy and also
  prevents the post-kill continuation cascade from one wobbled turn.
2026-11-15 17:29:08 +08:00
ework-agent 268280f02b fix(gate): forward a/b/u skips to release-gate-local as its CLI flag
The entrypoint exported GATE_SKIP but release-gate-local.mjs only reads the
--skip CLI flag — so --skip a/b/u was a silent no-op (observed live: a run
launched with GATE_SKIP=a,b,u still executed all three lanes). The P/R/I/X
scripts DO read GATE_SKIP themselves, so only the a/b/u subset needed
forwarding. Observed in the 2026-11-15 0.1.215 full-gate run.
2026-11-15 15:37:44 +08:00
ework-agent cd817f697e fix(gate): cache-ratio check evidence-only when the upstream reports no usage; keep config off argv
Review follow-ups on this PR:

- restart-lanes: the lane contract (header + README) says the cache-hit
  recovery ratio is asserted 'whenever the upstream reports usage
  details' and is evidence-only when it does not — but the code recorded
  ok=false in the no-pair case, turning an upstream that strips usage
  details (environment fact, same class as Lane P's ENV-BLOCKED demotion)
  into a red lane. Now: ZERO usage records on the wire → evidence-only,
  out of the tally; usage present but no prev-prompt/next-cached pair →
  the cache plainly did not recover, stays red.
- bili-gate.sh: the config JSON was passed through "$(cat ...)" argv to
  node -e, exposing any apiKey values in ps during the parse window.
  The path is passed and node reads the file itself.
2026-11-15 15:24:48 +08:00
ci-check cf10455b73 fix(gate): make bili-gate.sh required-key check actually fail fast
The jget() helper was meant to treat model1.baseUrl / model1.model as
required (no default arg) and fail before the docker build, but the
unset-$2 default collapsed to "" (a string), so node's argv[3] was never
undefined and the process.exit(3) required branch was dead code. A config
missing model1.baseUrl silently produced MODEL1_BASE_URL= and proceeded to
a full image build before the container entrypoint caught it.

Pass an explicit has-default flag so a missing required key now fails fast
with the documented FATAL message (exit 2). Optional keys (all called with
a default) are unaffected.

Review fix for #6798 (小问题直接修).
2026-11-15 14:52:27 +08:00
ework-agent 67eeb303aa feat(gate): containerized full real-model gate + config-driven launcher
The full real-model gate (A compression / B model switch / U registry /
I install / X auto-update / P host-plugin lanes / R restart kill matrix)
moves into this repo so the lane logic versions with the code under test
and remote CI can run the SAME scripts from the candidate checkout.
Lanes I/X/R and the A/B model calls need a real model endpoint, so they
remain operator-run via the new launcher; ci-gate-plugins.yml keeps
driving Lane P.

- Dockerfile: node:22-slim + the host CLIs pinned to the versions this
  repo's own CI uses (dsh / pi / codex / opencode / claude / opencode-v1)
- entrypoint.sh: build the candidate rev, in-container ephemeral verdaccio
  (lanes U/I/X, no host registry dependency), keyed-API shims, then run
  release-gate-local (A/B/U) + plugin-lanes (P) + restart-lanes (R) +
  docker-lanes (I/X) and roll up one GREEN/RED
- docker-lanes.mjs / restart-lanes.mjs / patch-gate.mjs /
  verdaccio.config.yaml: the lane drivers and shims
- bili-gate.sh: config-driven launcher — scripts/gate/bili-gate.sh
  --config <path> [--rev REF] [--skip ...] [--keep] [--dry-run]. ALL
  host-specific facts (model endpoints, API keys, npm registry, git
  proxy/mirror, out dir) live in the local JSON config only; nothing
  machine-specific is committed here (config.example.json is
  placeholders). The stale-image guard from the old host wrapper comes
  along: on build failure the existing image is reused only after
  byte-comparing every /gate-tools lane script, drift = FATAL.
- README(.zh-CN): full lane table + the endpoint/secret contract +
  how-to-run; the old 'the containerized wrapper lives outside this repo'
  section is retired
2026-11-15 14:38:50 +08:00
ework-agent d7cd5485e8 fix(gate): plugin-lane claim via index.db, resp-body tail + latency on wire log
plugin-lanes.mjs — bring the lane script forward to the state that ran the
#6552 full gate (the repo copy predated it):

- plugin claim is read from the sessions index.db metadata FIRST and the
  JSONL envelope scan is kept only as a fallback. Pure-SQLite has been the
  storage default since 2026-11-13, so JSONL-only claim checks could go red
  on a perfectly healthy session (that is exactly what the #6552 gate
  review found — the data sat in index.db while the lane asserted on the
  JSONL that was never written).
- CODEWORDS / buildCorpus are exported: restart-lanes.mjs reuses the same
  corpus generator (commit 2).
- requireSync via createRequire (node:sqlite is loaded lazily, only when a
  candidate session actually has an index.db).
- keep the recorder-spawn comment for the 2026-11-14 wedged-tee fix.

upstream-recorder.mjs — record a capped 256KiB rolling tail of each response
body plus per-request ms: usage / cached_tokens live in the FINAL stream
chunk, and Lane R's cache-hit assertions read them from the recorded tail.
Sensitive headers (authorization / x-api-key / cookie / ...) stay masked —
bili forwards the model API key into this hop on every request.
2026-11-15 14:38:41 +08:00
ranxianglei f31b7103bc gate: stop the upstream recorder from wedging the gate on aborted lanes
The recorder was spawned with stdio ['ignore','ignore','inherit'] and
detached:true. When a lane aborted before its own teardown, the detached
recorder kept the inherited stderr open — which, in the entrypoint's
'| tee lane.log' pipeline, is the very pipe the entrypoint waits on.
The whole gate then sat in do_wait until someone killed the recorder
(observed 2026-11-14: master candidate run wedged 3h after the restart
lanes; I/X never ran).

- stderr goes to a per-lane recorder.stderr.log instead of the lane's
  inherited log pipe (a leaked recorder is now harmless).
- main()'s per-agent catch SIGKILLs the in-flight recorder so aborted
  lanes do not leave orphans behind.
2026-11-14 15:44:26 +08:00
ranxianglei 984d3dcb5f fix(gate): opencode lane one-time warmup round for fresh storage dirs (PR #3497) 2026-11-08 12:09:17 +08:00
awork d58fa2c356 test(gate): extend recall tool-use ban to plugin lanes (same S07 flake vector)
scripts/gate/plugin-lanes.mjs carries the identical folded-recall prompt at t2 (:395) and t4 (:473) — same "Without reading any file again" wording the local gate fixed in 9bae4fae9. Plugin lanes drive real host CLIs (dsh/pi/codex/claude/opencode), whose models can equally detour into search_context/decompress/shell during the recall turn and leave an empty final, false-reding the assertion (#4028). Apply the same hard constraint so the mechanism family is closed in one PR (#4028, found during #4029 review).
2026-10-23 13:40:10 +08:00
ranxianglei 0bcfd1ef9f gate: give claude's small-window preflight marathon a 600s turn budget
t3/t4 at the derived small window trigger a multi-stage distillation
(observed 297s of local preflight work for a 170KiB history — the #3452
first-sight marathon shape); the shared 300s turn budget SIGTERMs the
CLI mid-preflight (turn artifacts empty, 'summarization aborted: client
disconnected'). 600s keeps the lane asserting the fold path itself
instead of racing the summarizer.
2026-10-19 14:51:09 +08:00
awork eb56cb756f feat(gate): dsh protocol matrix + proxy lane with per-door wire assertions (#3475)
Extend the dsh gate lanes from one protocol to all four pi-ai protocols
(openai-completions / openai-responses / anthropic-messages /
google-generative-ai) plus a dsh proxy-mode lane for same-host
two-activation-path contrast. Same headless driver and corpus flow; only
the cordis provider api + baseURL suffix differ per lane.

- per-door WIRE_EXPECT hard assertion: every recorder POST must match the
  door path regex AND body top-level shape; first request dumped to
  egress-sample.json as round-trip evidence
- blocked semantics: ENV-BLOCKED (door unhealthy: all-rejected or degraded
  mid-flow, opencode2/#3461 rule) and CLIENT-BLOCKED (client config surface
  cannot express the api yet — dsh's cordis schema lists no
  google-generative-ai in 0.2.0-rc.2 / 0.2.1-rc.1); excluded from tally,
  printed at exit
- calibration fixes from real-model runs: GATE_OUTPUT_TOKENS (thinking
  models degenerate when output budget < thinking budget), p1 = max over
  full post-t1 log, post-fold small-window widening for adaptive recipes,
  mid-seed guard, lane-local dsh install (GATE_DSH_VERSION) + lane TMPDIR
- t1 dual marker (S40+S07): verify the read precondition so downstream
  S07 recalls can't fail for fixture reasons

Existing lanes' generated configs are byte-identical to pre-#3475
(parity harness); new lanes are GATE_AGENTS opt-in. Local real-model run:
56/56 passed (dsh-responses:env, dsh-google:client).
2026-10-17 15:39:51 +08:00
ranxianglei eaa4c57036 gate(plugin-lanes): README in English + Chinese companion (#3475)
scripts/gate/README.md becomes the English document (repo docs are
English-first); the previous Chinese text moves verbatim to
README.zh-CN.md, cross-linked from both headers. Ref #3475.
2026-10-17 11:53:02 +08:00
ranxianglei 989bf4e805 gate(plugin-lanes): wire-seeded mid calibration, t2 retry hardening, opencode-v1 bin knob
- seed mid from the biggest t1 request body on the wire (idle log lines
  lag the corpus read; a stale line put dsh t2 at 285% usage and the
  EMERGENCY nudge rode a fail-fast 502 that never forwarded)
- t2 retry: up to 3 attempts, require in-band + ok + non-empty + the
  S07 marker (wrong-marker answers get one cheap retry)
- dsh setWindow rewrite all contextWindow entries (multi-model cordis)
- opencode v1 bin honors GATE_OC1_BIN (image installs it as opencode-v1;
  plain 'opencode' resolves to the v2 line whose managed service fights
  the port and crashes at cli.server-connect)
2026-10-17 11:42:49 +08:00
ranxianglei c68a8b42a3 gate: claude-proof the t1 corpus prompt (Read elides middles; force explicit chunk reads) 2026-10-17 10:49:31 +08:00
ranxianglei 25984c90eb gate: isolate zone ports per lane + survive dsh boot model-info race
- BILI_ZONE_PORT per native lane (19000+hash): a leftover proxy on the
  default 18787 can no longer capture a lane or force a mid-run drift
- BILI_MODEL_INFO_RETRY_MS=1000: the dsh native plugin's boot-time
  model-info resolve races the host's provider-adapter registration
  ("no adapter registered"), and the failure shape eats a 30s cooldown —
  longer than a whole short headless turn; 1s retry + a leading cheap
  bash tool call per prompt (warmupPrefix) guarantees request #2+ lands
  with the x-bili-plugin-context-window header stamped
- t3/t4 retry loop (2x) absorbs tag-echo-only empty replies
2026-10-17 10:21:39 +08:00
awork eecdcf2bb1 fix(gate): align stray indent in plugin-lanes mid-window loop (#3462 review) 2026-10-17 09:44:43 +08:00
awork 68297ea934 fix(gate): mask auth headers in upstream-recorder JSONL (#3462 review)
The recorder logged every request header verbatim; bili forwards the model API key into this hop on every request, so the key landed in upstream.jsonl on disk. Mask authorization/proxy-authorization/cookie/x-api-key/api-key values, and warn once on stderr if the JSONL cannot be written instead of swallowing it silently.
2026-10-17 09:44:43 +08:00
ranxianglei 5cfd56f602 gate: plugin lanes in-repo — real host CLIs x real model (#3416)
scripts/gate/plugin-lanes.mjs + upstream-recorder.mjs: drive dsh/pi/codex/
claude/opencode through native and /bili/ prefix lanes against a real model,
asserting on the recorded wire (tools declared, hard nudge-on-wire, fold,
marker recall, no unknown-tool loops). ci-gate-plugins.yml is manual-only
(workflow_dispatch, no push/PR trigger, skips green without an endpoint
secret). Container harness stays out of the repo.
2026-10-17 09:27:01 +08:00