Skip to content

Agent Capability [Mature-Library Inventory Matrix] ​

Status: Decided (2026-10-07): all 16 "replace/keep/add" conclusions are endorsed; batches A–F execute in order — A (backoff) → B (x/time/rate rate limiting) → C (jsonschema response validation) → D (kin-openapi differential comparison; risk-gated, can be halted independently) → E (local gateway TLS; the either/or resolved to wiring) → F (internal-defect batch). Each batch proceeds as an independent PR/commit; the next batch starts only after CI is green; progress is written back into this section. The decision rationale is in the "Decision Record" section. Progress (2026-10-07): A backoff has landed (a9d250e, including differential-comparison and injection-point cases); B the rate-limit bucket layer has landed (this commit: tokenbucket.go switched to x/time/rate; the new-vs-old admission-sequence differential cases are carried by an in-test copy of the old bucket; TestSlidingWindowWaitVariants got timestamp injection to de-flake; behavioral difference: Wait now fails immediately when the ctx deadline precedes the next-token time instead of blocking until the deadline, so the openapi provider's Call returns fast and no longer burns the caller's ctx for nothing); C jsonschema/v6 response validation has landed (this commit: extractOutputSchema extracts the schema of 2xx application/json responses (both 3.x and 2.0 shapes, $ref resolution reusing the input-side machinery) → Call validates after Transform; no schema means skip, a compile failure degrades to a warning (nothing broken), and data mismatch hard-fails into the existing error-reporting channel; positive/negative + compatibility + degradation cases). D leftover hook: ProviderFunctionDescriptor.output_schema (provider.proto:24) is consumed by the entire downstream chain (agentlocal→server→registry) but never filled by the agent registration side — to be evaluated and filled with batch D (filling it brings the spec-derived schema into the registrationguard display-key guard surface and needs its own regression). E local gateway TLS has been wired (this commit: the tls: section is built via the newly exported tcptr.BuildServerTLSConfig (reusing the Server's TLS semantics: MinVersion 1.2, CAFile → mTLS RequireAndVerifyClientCert, insecureSkipVerify → NoClientCert, missing certFile/keyFile fails at startup) into a server-side *tls.Config injected into TCPLocalListenerConfig.TLSConfig, delivered downward by App.WithLocalTLSConfig; the listener wraps each connection with tls.Server+HandshakeContext (10s handshake timeout); the reason tls.NewListener is not used: a failed handshake would surface from Accept and kill the whole Accept loop, whereas per-connection wrapping drops only the current connection (plaintext probing/scanning is non-fatal; a case locks this in); config-agent.md and sdk-wire-protocol.md synced. Known boundary: the six-language SDKs have no TLS dial option yet (each SDK to follow up independently; the wire protocol is unaffected; keep tls.enabled: false until the SDKs catch up). Batch F incidental finding: the outboundTLS chain is another case of "config promised, implementation missing" — after localHandler.SetTLSConfig stores h.tlsCfg there are zero consumers (callLocalProvider always dials the fallback address with Insecure: true), and config-agent.md's outboundTLS section ("Agent Server link TLS") has drifted from the actual assembly (upstream TLS is actually driven by the server: section; root.go reads only c.Server.*) — to be wired or removed with batch F (landed: the outboundTLS wiring shipped as independent commit 2ddc5ae; callLocalProvider dials with the injected ClientTLSConfig and nil keeps the plaintext compatibility path; the config-agent.md outboundTLS drift has been corrected in sync — reworded to "TLS on the Agent → local Provider outbound call chain" and stating the division of labor with the server: section). F landed (62d16c6 F-1: the AutoRestart delay moved out of p.mu + stopCh is interruptible, with new no-lock/interruptible-stop regression cases; errorAs deleted in favor of errors.As plus a %w-chain recognition case; the RWMutex fatal item was re-checked and already has a dedicated regression on file, no change needed. This commit F-2: the session double abstraction converged per the §15 execution ruling by deleting the zero-consumer internal/transport/session package outright). Capability matrix batches A–F all complete (2026-10-07). Assessment conclusion (at D's landing): not filled with D — the only current consumer of the output schema is agent-side runtime validation (batch C closed the loop); the dashboard has no output-schema rendering surface yet, and filling it would make the x-* display keys in the spec subtree collide directly with registrationguard's registration refusal — more damage than benefit. Deferred until a real "the dashboard needs to render the output schema" requirement appears, chartered separately together with a guard-exemption/stripping policy. Progress addendum (2026-10-07, D): the D kin-openapi differential comparison has landed (the input_schema derivation main path now uses kin, kinInputSchemas/extractInputSchemaKin; the old map traversal demoted to a compatibility fallback). The comparison corpus is 15 fixtures (the existing 6 fixtures plus allOf/nullable/vendor-ext/no-schema params/header-cookie/enum-format-default/no operationId/nested-property $ref/3.1 type arrays/2.0 fallback/dangling external-ref fallback), JSONEq-aligned operation by operation. Ruling record: ① kin's LoadFromData does not validate the version and loads 2.0 docs too — but 2.0 semantics are not faithfully preserved, so kinInputSchemas explicitly restricts to OpenAPI prefixes 3., everything else falls back to the old path; ② kin refuses dangling/external $refs → same fallback (the old implementation's dangling-degradation semantics are preserved by the fallback path); ③ zero diffs in the comparison (0/15 < the 5% gate, no halt). validator.go's business validation and rest_classifier's semantic classification remain untouched per the migration path. Method: gone through file by file against what the code actually implements (internal/agent/, internal/app/agent/, internal/transport/, pkg/protocol/, internal/platform/{agentlocal,openapi,ratelimit,tlsutil}, internal/devcert, cmd/sidecar-agent/ (named sidecar-agent; option A landed 2026-10-11, see Agent inventory §9)); each candidate library's maintenance liveness verified (stars / latest release / downstream adoption / packaging status); verification date 2026-09-23. Verdict vocabulary: replace (a clearly better mature library exists; migration path attached), keep (in-house is a reasonable end state; reasons attached), add (the capability is missing and a mature library should be introduced). The rule "three months without maintenance = disqualified; better to keep the in-house code" is enforced strictly; the exception discussion for "small finished libraries" is in each item's notes.

Why This Inventory (Overview) ​

The bugs exposed by agent testing and production incidents cluster in the corners of in-house infrastructure: a transport-layer JSON/proto layering error (the 19-function sync failure incident, fixed twice in 942e1bf4e/4a9a67cd6), five data races self-documented in comments (app.go:47-50, upstream.go:31-32, ops_server.go:42-44/410-414, tcp_local_listener.go:197-201) plus one fatal RWMutex misuse, three reconnect-backoff implementations behaving differently, and rate-limit windows going flaky on slow machines. The common shape of these bugs: hand-rolled wheels re-implemented mature problem domains (backoff scheduling, concurrent shutdown, rate-limit boundaries) and then re-stepped on the pitfalls the industry already stepped on, inside their own implementations.

But the inventory equally found that the agent's protocol layer is not a wheel — it is a product contract (framing/protocol header/MuxConn): all six language SDKs implement this wire protocol (docs/architecture/sdk-wire-protocol.md); replacing it equals rewriting every SDK. So the right output of this inventory is not "replace everything with libraries" but hand "domain problems" to mature libraries (backoff/rate limiting/validation) while keeping "product contracts" in our own hands (protocol/session/scheduling semantics), plus cleaning up known internal defects in the in-house code.

Decision Record (2026-10-07) ​

What was decided: all 16 conclusions of the matrix are endorsed along with the section-3 batch order; two open questions settled here — ① batch E's "wire it or remove the config item" either/or resolved to wire it (the AgentTLSConfig config promise already exists; a dead config item violates the boundary-honesty principle; TLS sits above TCP and below framing, so the six-language SDK wire protocol is unaffected — each SDK only needs a TLS dial option); ② batch order A→B→C→D→E→F, with D (kin-openapi differential) as the risk-gated batch — an excessive comparison diff halts D alone without blocking A–C.

Why: ① the three replacements (backoff / rate limiting / schema derivation) are all direct evidence of "domain problems hand-written, then industry pitfalls re-stepped" (slow-machine flake, thundering-herd risk, derivation corners), and every candidate is an official/ecosystem standard or already a dependency of this repo (zero new-adoption cost); ② the keeps are either product contracts (wire protocol/MuxConn; replacing = rewriting six SDKs) or have disqualified candidates (robfig/cron is unmaintained) or have no qualified candidate (process management/devcert); ③ the two additions (jsonschema validation, local gateway TLS) are both make-up work for "config/contract promised but implementation missing", incremental and non-breaking.

Alternatives (rejection reasons): replace everything (yamux/smux for MuxConn etc.) — mistaking request/response multiplexing for stream multiplexing, moving complexity elsewhere for a rewrite that also drags six SDKs, wiping out all production validation; keep everything as-is (execute no batches) — A/B's thundering-herd backoff and rate-limit flake are real failure shapes already recurring in production and on slow machines; ignoring them is the risk.

Re-review hooks: a batch-D comparison diff rate >5% or an undecidable item halts D and is written back here; yamux/smux candidates are re-evaluated if "single-connection bandwidth bottleneck / hundreds of concurrent streams" needs appear; koanf is introduced on demand once the config compatibility layer is fully retired.

1. The Matrix ​

#CapabilityCurrent implementation (file:line)Mature candidateLiveness evidenceLicenseVerdict
1Reconnect/retry backoffinternal/app/agent/upstream.go:317-349 (fixed 5s polling), 464-497 (hand-written 200ms→2s doubling), openapi/provider.go:843-856 (linear i+1 seconds) — three implementationscenkalti/backoff/v5v5.0.3 (2025-07-23), ~30k dependent repos, being packaged for Debian/GuixMITReplace
2Token-bucket rate limitinginternal/platform/ratelimit/tokenbucket.go (73 lines) + advanced.go (570 lines), hand-written channel implementationgolang.org/x/time/rateOfficial Go extension repo (golang.org/x), Google-maintained, the rate-limit implementation recommended by the official wikiBSD-3Replace
3OpenAPI schema derivationinternal/platform/openapi/input_schema.go (207 lines) + rest_classifier.go (155 lines) + validator.go (179 lines), hand-written 3.0.3 derivationgetkin/kin-openapiv0.144 (already in this repo's go.mod), supports 3.0/3.1/3.2, CVE-2025-30153 fixedMITReplace (after differential)
4JSON Schema validationNone (InvokeResponse data passes through unvalidated)santhosh-tekuri/jsonschema/v6v6.0.2 (local go.mod), covers drafts 4–2020-12, adopted by oapi-codegenApache-2.0Add
5Local gateway TLSDead config item: cmd/sidecar-agent/root.go:124-131 defines AgentTLSConfig, but internal/agent/tcp_local_listener.go never wires it(No library needed; stdlib crypto/tls already in use)——Add (wiring, not a library)
6TCP framing + protocol headerinternal/transport/tcp/framing.go:14-50 (50 lines), pkg/protocol/message.go (296 lines)No qualified candidate (custom protobuf framing is a product contract)——Keep
7Bidirectional multiplexing (MuxConn)internal/transport/tcp/mux_conn.go:62-489 (489 lines, two-lane dispatch)hashicorp/yamux, xtaci/smuxyamux 0.1.2 (new version marked in Debian 2025-11), libp2p default; smux v1.5.x active (references updated 2026-03)MPL-2.0 / MITKeep (candidates on record)
8Load balancing (sticky hashing)internal/agent/local_handler.go:373-426,749-759 (FNV-1a modulo, ~70 lines)buraksezer/consistent and other consistent-hash librariesNot specifically verified (weak candidate)—Keep
9crontab/systemd timer parsinginternal/app/agent/systemd_parse.go (237 lines, read-only enumeration)robfig/cron/v3 parserZero releases since v3.0.1 (2020), 50+ open PRs backlogged — disqualified by the ruleMITKeep
10YAML config loading + legacy-key compatibilitycmd/sidecar-agent/root.go:78-465 (~390 lines, four UnmarshalYAML compatibility layers)knadh/koanf v2 (MIT, active), spf13/viper (active, heavy)koanf v2 active (pkg.go.dev docs continuously updated)MITKeep (shrink only, never grow)
11Loggingstdlib slog + lumberjack rotation (internal/cli/common/logging.go)The current combination is already the ecosystem standardlumberjack is the de facto log-rotation standard in the Go ecosystemMIT (lumberjack)Keep
12TLS/dev certificatesstdlib crypto/tls + internal/devcert/devcert.go (227-line self-signed CA)No embeddable equivalent (mkcert is a CLI, not a library)——Keep
13Process management (OpsServer)internal/app/agent/ops_server.go (604 lines, os/exec + allowlist + 300s cap + managed-process start/stop)No dominant Go process-management library——Keep (internal defects fixed separately)
14HTTP client (openapi provider)internal/platform/openapi/provider.go (1115 lines, stdlib net/http)go-resty/reqActive (ecosystem mainstream)MITKeep (retry switches to backoff with #1)
15Session/registryinternal/agent/provider_session.go (210 lines) and internal/transport/session/* (378 lines) two coexisting sets(An internal-convergence problem, not a library swap)——Keep + internal convergence
16Serializationprotobuf (google.golang.org/protobuf v1.36.12) + scattered JSON layering violations (mux_conn.go:193,422, local_handler.go:422,509-519)The current protobuf is the right answerThe official protobuf Go runtimeBSD-3Keep (layering violations close out with #4)

Capabilities the agent does not have and should not adopt (items on the user's list unrelated to the croupier agent's mission): browser automation, screenshots/vision, running and parsing tests, Git operations, arbitrary file read/write APIs. The croupier agent is a GM-infrastructure agent (function registration/invocation/tasks/ops inside the game network); the above belong to the capability surface of general automation agents, and adopting them only grows the attack surface (ExecuteCommand's allowlist gate exists for exactly this reason). This is a boundary decision, not a capability gap.

2. Item-by-Item Argument ​

1. Reconnect/retry backoff [Replace (cenkalti/backoff/v5)] ​

Why it is a problem: three backoffs coexist in the same codebase — upstream reconnect is fixed 5s polling (no exponentiation, no jitter), registration sync is hand-written 200ms→2s doubling, and the OpenAPI provider retries linearly at i+1 seconds. Three inconsistent implementations are a maintenance burden in themselves, and fixed 5s polling carries a concrete failure-amplifier risk: when the server restarts, N agents redial simultaneously at the same 5s phase (no jitter against the thundering herd) — exactly the reconnect pressure behind past incidents like "dual-instance registry view split" and "cpp demo reconnect hang". The hand-written doubling has no ceiling jitter; under a long outage it plateaus at 2s and beats at a fixed rate.

Why this library: cenkalti/backoff is the de facto Go backoff standard (this repo's go.mod already carries v5 as an indirect dependency — zero new-adoption cost); NewExponentialBackOff gives the four knobs (initial interval/multiplier/max interval/randomization), and NextBackOff() + ctx covers all three existing scenarios. ~30k dependent repos, still releasing as of 2025-07, being packaged for Debian/Guix — liveness undisputed.

Migration path (low risk, cohesive interface):

  1. upstream.go's reconnectLoop: backoff.NewExponentialBackOff (InitialInterval=5s, Multiplier=1.5, MaxInterval=60s) + backoff.WithContext preserving ctx cancellation semantics; Reset on successful reconnect. The default randomization provides anti-herd jitter for free.
  2. upstream.go's syncWithRetry: same library replacing the hand-written doubling (InitialInterval=200ms, MaxInterval=2s; the existing ceiling semantics unchanged).
  3. openapi/provider.go:843-856 retry loop: linear i+1 seconds → backoff.ConstantBackOff first (behavior-equivalent); exponentiation evaluated separately later if wanted.
  4. Tests only grow: keep the existing backoff cases; add "backoff sequence within the exponential upper bound" and "immediate exit on ctx cancellation".

Risk: the changed reconnect timing may break cases/ops scripts assuming "fixed 5s" — the migration PR greps out all hardcoded 5s assertions; TestGoMigrations-style smoke tests are unaffected.

2. Token-bucket rate limiting [Replace (golang.org/x/time/rate)] ​

Why it is a problem: ratelimit/tokenbucket.go is 73 lines of hand-written channel-based token bucket + 570 lines in advanced.go. This repo's TestSlidingWindowWaitVariants is known to flake repeatedly on slow machines (memory archive on file) — hand-written rate limiting's waiting semantics are timing-sensitive, direct evidence of "domain problems hand-written, industry pitfalls re-stepped". x/time/rate's Limiter keeps accounts on a monotonic clock rather than counting on a channel; the slow-machine wait-window drift shape cannot occur.

Why this library: golang.org/x is the official Go extension standard library — Google-maintained, perpetually active, BSD-3 with no licensing burden; the official Go wiki explicitly recommends it for token-bucket scenarios. Limiter.WaitN/Reserve/AllowN covers the openapi provider's three call shapes (blocking wait / reservation / direct admission). It does not cover sliding-window semantics — if advanced.go holds window logic (e.g. per-minute quotas), keep the window layer and swap only the bucket layer to x/time/rate; the two layers' responsibilities actually get clearer.

Migration path:

  1. Inventory every caller of tokenbucket/advanced (openapi provider rate limiting, the ops surface) and list the current semantics matrix (burst, waiting, rejection).
  2. Replace the bucket layer with rate.NewLimiter(rate.Limit(rps), burst); waiting paths use Wait(ctx), non-blocking paths Allow().
  3. New differential cases: with identical parameters, the first N admissions of old vs new must match (locks the behavioral contract); slow-machine flaky cases are converted to injection-point driven (aligning with the prefer-injection-over-timing-tests memory rule).
  4. Keep the old implementation one release cycle under a deprecation comment before deleting.

Risk: behavioral differences concentrate in "boundary burst" shapes — the differential cases exist for exactly that; window semantics stay in the original layer, so the externally observable rhythm is unaffected.

3. OpenAPI schema derivation [Replace (after differential; getkin/kin-openapi)] ​

Why it is a problem: 207+155 hand-written lines derive the schema→function-signature mapping for 3.0.3 specs. OpenAPI's corners (allOf/oneOf composition, nullable, recursive $ref, default vs example precedence) cannot be fully covered by hand; the diversity of game-side specs is uncontrollable, and each new game onboarded may add a derivation bug. kin-openapi is already a dependency of this repo's go.mod (in use server-side; v0.137/v0.144 in the local cache), supports 3.0/3.1/3.2, and responded fast to the 2025 CVE (CVE-2025-30153 patch released).

Why "after differential": this is not a pure internal implementation swap — the derivation result directly determines the function contract (inputSchema) registered to the platform, and behavior changes propagate to UI form generation and SDK validation. A comparison corpus must come first: collect the specs for all existing providers.yaml, run both implementations side by side, and adjudicate every diff by hand (old-right/new-wrong → fix the new implementation; old-wrong/new-right → record as a fix); switch only when the comparison is fully green.

Migration path: build the comparison corpus (snapshot existing specs into testdata) → rewrite input_schema derivation on the kin-openapi parsing layer → differential comparison → switch → delete the old derivation code. validator.go's business validation (platform constraints) stays; only the "spec parsing + schema traversal" layer is replaced.

4. JSON Schema validation [Add (santhosh-tekuri/jsonschema/v6)] ​

Why it is missing: the agent passes provider-returned InvokeResponse data straight through to server/web with no schema-level validation; the proto/JSON layering violations (mux_conn.go:193,422 stuffing {"error":...} JSON strings into proto payloads) show that boundary validation of structured output was absent from the start — one root cause of the 19-function sync incident was error-shaped data entering the normal data channel. Once OpenAPI 3.1 support lands (#3), response schema validation has an authoritative source, and adding it closes the loop.

Why this library: v6 is the only actively maintained Go implementation covering drafts 4–2020-12 (gojsonschema stopped at draft-07 and is effectively dead), adopted in production by oapi-codegen, already in this repo's go.mod (in use server-side), Apache-2.0. It shares lineage with kin-openapi v0.136+'s internals (kin's 3.1 support is built on it), so the combination adds no conceptual cost.

Migration path: InvokeResponse gets schema validation (enabled when a response schema exists, skipped otherwise — compatible with existing providers) → validation failures go through the existing error-reporting channel (never silently swallowed) → new positive/negative cases.

5. Local gateway TLS [Add (wiring, not a library)] ​

The AgentTLSConfig config surface exists (root.go:124-131) but tcp_local_listener.go consumes only Address/RecvTimeout/SendTimeout — the config item is dead; users can set it with no effect. That is "config promise vs implementation mismatch", and the boundary-honesty principle requires either wiring it or explicitly removing the config item. The implementation needs only stdlib crypto/tls (the outbound direction already uses the same pattern; client.go:165-196 can be copied). The either/or: wire it (recommended — plaintext SDK↔Agent local TCP on shared hosts is a real exposure), or delete the field from the config struct and note the boundary in the docs. Wiring is recommended, because the frame format is unaffected (TLS sits above TCP, below framing), and the six-language SDKs only need a TLS dial option.

6. TCP framing + protocol header [Keep] ​

50 lines of framing + 296 lines of protocol header look like "a wheel" but are a product contract: the six language SDKs (go/python/java/js/cpp/csharp) each implement the same wire protocol, and docs/architecture/sdk-wire-protocol.md is its specification. No replacement candidate exists — any third-party framing (gRPC framing, msgpack-rpc, etc.) is a protocol change costing a full SDK rewrite plus a compatibility window, for negative benefit (the current protocol is simple and proven in six languages). Keep; and the historical bug here (19-sync) was fixed in the layering semantics, not the frame format itself.

7. MuxConn bidirectional multiplexing [Keep (candidates on record)] ​

yamux (hashicorp, libp2p default, 0.1.2 active) and smux (xtaci, v1.5.x active) are both qualified and mature. Still keep, because MuxConn is not stream multiplexing — it is request/response semantics multiplexing: a pending map keyed by reqID, a control lane with 1 worker that never rejects, and a business lane with a bounded queue that answers busy frames under saturation to trigger the peer's failover — this semantics is deeply coupled to the GM invocation model of "server broadcast / agent unicast / failover". yamux/smux provide a stream abstraction; adopting them means building another request/response correlation layer on top of streams — rewriting MuxConn's complexity somewhere else, plus syncing six SDKs. All production validation (converged after the 19-sync incident) would be wiped and redone. Candidates on record: if "single-connection bandwidth bottleneck" or "hundreds of concurrent streams" needs appear, re-evaluate smux v2 as the base. Incidental cleanup: delete the hand-written errorAs at mux_conn.go:44-54 and use errors.As directly.

8. Load balancing FNV sticky hash [Keep] ​

70 lines of FNV-1a modulo instance selection. Consistent-hash libraries (buraksezer/consistent etc.) solve "mass key migration on dynamic node-pool scaling"; the agent scenario is a handful of instances of one game service (the registry indexes by (game_id, function_id)), so stickiness is enough and migration minimization is unnecessary. Swapping a library here is a cannon for mosquitoes, plus a new dependency. The 30s health window + degrade-on-all-stale semantics are kept.

9. crontab/systemd timer parsing [Keep] ​

robfig/cron/v3 is disqualified by the rule: zero releases after v3.0.1 (2020), 50+ open PRs backlogged, community forks already appearing. And the requirement, examined closely: the agent only does read-only enumeration for display (reading /etc/crontab, /etc/cron.d, and the systemd timer list for the ops surface), not scheduling execution — it depends on field splitting, not on the parser's scheduling correctness. The 237-line in-house parser covers exactly "loose parsing for display"; adopting a dead-project library would just bind its CVE risk. If scheduling semantics like "next trigger time of an expression" are ever needed, evaluate an active fork or systemd's native NextElapse (via D-Bus; availability under LXC to be discussed then).

10. YAML config compatibility layer [Keep (shrink only, never grow)] ​

koanf v2 is active (MIT, modular, light dependencies); viper is active but heavy. Do not adopt, because the 390-line compatibility layer's body is not "YAML parsing" (yaml.v3 already does that) but business rules — the dual-read mapping of PascalCase/snake_case legacy spellings (four UnmarshalYAML layers in root.go). koanf ships none of those rules; after adoption you would write the same mapping code — a shell swap, not a brain swap. The real governance path is already fixed in CLAUDE.md's config contract: new keys are always canonical lowerCamelCase; the compatibility layer shrinks only, never grows; once legacy keys die out naturally, delete the layer wholesale. If a modern config layer (layering/env vars/file hot-reload) is wanted then, koanf is the first candidate at that time (on record).

11-14. Logging / TLS+devcert / process management / HTTP client [Keep] ​

  • Logging: slog (stdlib) + lumberjack is already the Go ecosystem's standard combination; no action.
  • TLS/devcert: stdlib crypto/tls for outbound is the right answer; the 227-line devcert self-signed CA is a developer-experience component, and mkcert-class tools are CLIs that cannot be embedded as libraries — no qualified replacement.
  • Process management: Go has no dominant process-management library; OpsServer's real defects (AutoRestart time.Sleep under lock, no process-tree termination, output not demultiplexed) are bugs fixable within the in-house code — listed in the "keep + internal defect list" and fixed in normal iterations; not a reason to swap libraries.
  • HTTP client: the provider's complexity is the spec→HTTP semantics mapping (the 1115-line body), not HTTP itself — nothing in net/http that resty/req would improve. The only thing worth replacing is the retry loop's linear backoff, handled along with #1's backoff migration.

15. Session/registry double abstraction [Keep + internal convergence] ​

internal/agent/provider_session.go (210 lines) and internal/transport/session/* (378 lines) overlap functionally, two sets coexisting. This is not a library-swap question but internal convergence: designate one as standard (transport/session is the more general one; the agentlocal registry was thought to depend on it), migrate and merge the other, then delete. Listed in the internal defect list, handled in an independent PR (mind the boundary constraints from the registry import cycle memory).

Execution ruling (at F's landing, 2026-10-07): verification before landing found internal/transport/session has zero consumers repo-wide — no imports from production code or out-of-package tests (the original text "the agentlocal registry already depends on it" had drifted from reality; agentlocal carries its own ProviderSession struct definition). The convergence direction flipped to keep the live one, delete the dead one: agent/provider_session.go is the implementation actually wired into tcp_local_listener/app and validated in production; transport/session/* is a parallel abstraction with no production mileage — migrating live code onto a zero-validation abstraction is pure risk for no benefit. Deleted wholesale (including its in-package tests); provider_session.go is now the sole session abstraction.

16. Serialization layering violations [Keep + close out with #4] ​

The official protobuf runtime is the right answer. The two JSON-into-proto-payload layering points (mux_conn.go:193,422, local_handler.go:422,509-519) are established conventions (the six language SDKs already align to this shape) and cannot be changed unilaterally — the close-out is #4's schema validation intercepting illegal shapes at the boundary; the protocol itself does not move.

3. Migration Path Summary (execution order after the decision) ​

BatchContentRiskTest strategy
A#1 three backoffs → cenkalti/backoff/v5 + #14's retry loop along the wayLow (cohesive interface; behavior parameter-equivalent + jitter improvement)Keep old cases + new backoff-sequence/cancellation pair
B#2 rate-limit bucket layer → golang.org/x/time/rate (window layer kept)Medium (boundary-burst differential)New-vs-old admission-sequence differential cases; slow-machine flaky cases → injection points
C#4 add jsonschema/v6 response validation (skip when no schema)Low (incremental capability, non-breaking)Positive/negative cases + no-schema compatibility case
D#3 OpenAPI derivation → kin-openapi (switch after differential)High (contract propagation)Switch only when the spec-snapshot comparison corpus is fully green
E#5 local gateway TLS wiring (or config-item removal; the either/or decided)Medium (SDK side needs a TLS dial option)TLS handshake integration cases
FInternal defect batch: errorAs removal, AutoRestart sleep under lock, session double-abstraction convergence, RWMutex fatal re-checkLow-mediumOnly grow, never shrink; -race -count=3

Each batch is an independent PR and independent commit; the next batch starts after CI is green. Batch D can be halted alone if the comparison diff is excessive, without affecting A–C.

4. Liveness Verification Evidence Archive ​

LibraryEvidence (verified 2026-09-23)
cenkalti/backoff/v5v5.0.3 released 2025-07-23 (pkg.go.dev/ecosyste.ms); ~30k dependent repos; Debian ITP 2026-05
hashicorp/yamux0.1.2 new version (Debian tracker marked 2025-11-27); libp2p's default muxer; Rust/JS ports exist
xtaci/smuxDebian packaging v1.5.57; pkg.go.dev/Sourcegraph references updated through 2026-03
golang.org/x/time/rateOfficial golang.org/x extension repo (Google-maintained); officially recommended in the Go wiki
getkin/kin-openapiv0.144 currently in this repo's go.mod; supports 3.0/3.1/3.2; CVE-2025-30153 patch released
santhosh-tekuri/jsonschema/v6v6.0.2 (local go.mod); drafts 4–2020-12; oapi-codegen production dependency; kin-openapi's 3.1 support is built on it
knadh/koanfv2 active (pkg.go.dev docs continuously updated); MIT; light dependencies
robfig/cron/v3Zero releases after v3.0.1 (2020-01), 50+ open PRs backlogged, community forks appearing — disqualified
gojsonschema (comparison item)Stopped at draft-07, no release after v1.2.0 — disqualified, hence #4 chose santhosh-tekuri