docs(solutions): gateway OpenCode mention-loop best practices#706
Conversation
fro-bot
left a comment
There was a problem hiding this comment.
Verdict: PASS
Docs-only PR adding a single best-practices learning file (docs/solutions/best-practices/gateway-opencode-mention-loop-best-practices-2026-05-30.md, +215). No executable code, no public API surface, no migrations. I verified the substantive risk for a learnings doc — that its claims and references match reality — and everything checks out.
Verification performed:
- All 7 referenced source files exist and the quoted snippets match the actual code:
remote-client.ts—createOpencodeClient({baseUrl, headers}), no-opclose/shutdown, fetch-based-SSE header note all match (the doc's claim is even backed by an in-source comment).opencode-attach.ts—attachOpencode(baseURL, token)→createRemoteOpenCodeHandle(baseURL, {Authorization: \Bearer ${token}`})` matches verbatim.workspace-agent/main.ts— ports54321/9200and127.0.0.1loopback binding match (doc omits that the proxy binds0.0.0.0, but that's implied by "sandbox-net-reachable").opencode-proxy.ts— length pre-check beforetimingSafeEqual, fixed 401 body all match.recovery.ts— thelockFetch.runId === run.run_idownership gate (line 144) andrunId: nullfail-safe (line 124) match the doc's P0 narrative exactly.run.ts—AbortSignal.timeout(runTimeoutMs)(206), catch-pathsink.flush().catch(...)(296), dual-finally withconcurrency.releasein outer finally (330–332) all match.run-core.ts— auth by numericstatus === 401 || status === 403(89),aborted → timeout(108),sawIdle === false → stream-ended(115) all match the doc's terminal-signal/auth claims.
- All 3 cross-linked docs exist (slash-command orchestration, webhook ingress hardening, resource-cleanup).
- Frontmatter is complete and consistent with the category/path convention (
category: best-practices, dated filename matchesdate:).
Blocking issues
None
Non-blocking concerns
- The proxy section (§2) says the bearer proxy is "the sole sandbox-net-reachable surface" but omits that it binds
0.0.0.0:9200while OpenCode binds127.0.0.1:54321. Stating both bindings explicitly would make the isolation model unambiguous for a future reader. Optional. - Filename date (
2026-05-30) and PR title (2026-05-30) agree, but the doc was captured "after the work cleared review" — fine as-is, just noting the date reflects capture, not the underlying work.
Missing tests
None — documentation has no testable behavior. The patterns it describes (recovery ownership gate, failure-path flush, dual-finally, terminal-signal) live in the gateway packages and are out of scope for this PR; this doc references them rather than introducing them.
Risk assessment (LOW/MED/HIGH): LOW
Single additive markdown file, zero deletions, no code paths touched. Blast radius is limited to documentation. Only failure mode for a learnings doc is inaccuracy or dead references — both checked and clean. No regression, security, or runtime exposure.
Run Summary
| Field | Value |
|---|---|
| Event | pull_request |
| Repository | fro-bot/agent |
| Run ID | 26705699650 |
| Cache | hit |
| Session | ses_18336700cffeoaCL7BR0JgA9eO |
|
Re-checked after the Verdict: PASSBlocking issuesNone Non-blocking concerns
Missing testsNone — documentation with no testable behavior; the patterns it describes already live in the gateway packages and are out of scope here. Risk assessment (LOW/MED/HIGH): LOWSingle additive markdown file, zero deletions, no code paths touched. The merge commit introduced no new changes to review. No regression, security, or runtime exposure. Run Summary
|
Captures the load-bearing patterns from the
@fro-botmention-execution loop as a best-practices reference, so later gateway work can reuse them instead of rediscovering them.Covers:
Authorizationheader on the/eventstream.run_idmatches the stale run before releasing, so recovery never deletes a newer run's lock.AbortSignal.timeoutplus nested finally blocks that always release the lock and concurrency slot.session.idleis a failure, not success; classify auth by numeric status, not message text.Cross-links the two existing gateway solution docs (slash-command orchestration, webhook ingress hardening) and the resource-cleanup doc as adjacent references.