Repository navigation
feat: resurrect all 99 cartridge adapters — 99/99 building and testing green - #114
Conversation
`adapter/build.zig` imports the sibling FFI as a Zig module, but the FFI sources declared bare `export fn`s and a private `const shim`. `export` alone gives a symbol C linkage; it does NOT make the declaration visible to another module through `@import`, so every adapter that referenced `ffi.boj_cartridge_invoke` (or needed the shim's `std.Io`) failed to compile. 2/118 FFI files had `pub export`; the other 116 did not. Mechanical across 129 files: `export fn` -> `pub export fn` (568 sites), and `const shim = @import("cartridge_shim.zig")` -> `pub const shim = ...` so adapters can reach the ONE process-wide `std.Io` the shim owns rather than standing up a second runtime alongside the cartridge. No shim copy is touched: `tools/sync_cartridge_shim.sh --check` reports 117 copies, 0 drifted. All 118 `ffi/` trees still green on `zig build test`. Co-Authored-By: Claude Opus 5 <[email protected]>
…hape
The template adapter is what `just mint` copies, so every future cartridge
inherits whatever it leaves behind. It was broken three ways at once, none
of them fixable by a Zig version bump:
* `main()` called `ffi.gossamer_init()` — a symbol that exists nowhere in
the sibling `ffi/`;
* `dispatch()` never reached the FFI at all. It matched a tool name and
returned a hand-written `"<tool> forwarded"` string, which contradicts
the adapter README's own "response passthrough" invariant;
* `build.zig` used `root_source_file` inside Executable/Test options, and
the listener used `std.net`, both removed in 0.16.
Rebuilt on the canonical unified-adapter shape documented in
`.claude/CLAUDE.md` and implemented by `k9iser-mcp`: ONE loopback listener,
protocol-classified (REST `/invoke`, SSE `/sse`, GraphQL `/graphql`,
gRPC-compat `/grpc/<Svc>/<Method>`), every request through the
`exposureSatisfied` transaction gate before a SINGLE dispatch into
`ffi.boj_cartridge_invoke`. The listener is ported to `std.Io.net` on the
shim's process-wide `std.Io`, and `build.zig` moves to
`createModule` + `.root_module`.
The adapter previously had zero tests, so its `test` step could not fail.
It now carries five: protocol classification, per-protocol tool extraction,
the dispatch funnel over every tool in `cartridge.json`, the
`exposureSatisfied` truth table, and `X-Trust-Level` parsing. Verified
failable — breaking one classification assertion turns the step red.
`zig build` and `zig build test` both green in `templates/gossamer-mcp/ffi`
and `templates/gossamer-mcp/adapter`.
Co-Authored-By: Claude Opus 5 <[email protected]>
Ninety `adapter/` trees are copies of one boilerplate. None of them built,
and no CI job ever ran them (`zig-test.yml` globbed only `*/ffi/`).
Per tree:
* `build.zig` regenerated on the 0.16 build API — `b.createModule(...)`
plus `.root_module`, replacing `root_source_file` inside
`ExecutableOptions`/`TestOptions`. Adds the `run` and `test` steps to
the trees that lacked them, and mirrors the sibling FFI library's
`link_libc` onto the embedded module (74 trees), which is what the
`undefined symbol` / `dependency on libc` failures were.
* The listener tail is ported from `std.net` to `std.Io.net`: sockets now
take an `io` handle, and it comes from the shared ADR-0006 shim
re-exported by the FFI module, so the adapter and the cartridge behind
it share ONE `std.Io.Threaded` rather than standing up two.
* `main()` called `ffi.<cartridge>_init()`, absent from every sibling
`ffi/`. Now `ffi.boj_cartridge_init()` with a matching `deinit`.
Two pre-existing format-string defects, independent of the version bump,
also had to go — both are why these files had never compiled at all:
* 24 trees wrote a multiline string literal with ONE backslash
(`\{{"success":…}}`), which is not a token;
* 19 trees passed a JSON object template to `bufPrint` without doubling
its literal braces, so `std.fmt` read the leading `{` as a placeholder.
The three-port REST/gRPC/GraphQL wire shape and every per-cartridge
dispatch table are left exactly as they were.
Co-Authored-By: Claude Opus 5 <[email protected]>
`k9iser-mcp` and `bug-filing-mcp` were the only adapters already on the canonical unified shape, and `k9iser`'s `zig build test` was green — but only because a test build never analyses `main()`. `zig build` failed on both: `std.net` does not exist in Zig 0.16. `writeHttp`, `writeSse`, `handleConnection` and `main` now take a `std.Io` handle and use `std.Io.net`; the handle is the shim's process-wide runtime, re-exported by the FFI module. Routing, the tool catalogue, the dispatch funnel and the `exposureSatisfied` gate are untouched, and all five inline tests still pass in each. Co-Authored-By: Claude Opus 5 <[email protected]>
`bsp-mcp`, `dap-mcp`, `lang-mcp` and `lsp-mcp` drive `std.http.Server`
rather than parsing HTTP by hand, so they needed a different port from the
cloned boilerplate:
* `std.http.Server.init` takes a `*Reader` and a `*Writer` in 0.16, not a
`net.Server.Connection` plus a scratch buffer;
* `Request.reader()` became `Request.readerExpectContinue(buffer)`;
* `std.mem.trimLeft`/`trimRight` are now `trimStart`/`trimEnd`;
* `{}` no longer formats an error value — `{t}` does;
* `build.zig` moves to `createModule` + `.root_module`.
Three of them also carried 46 inline `\{{…}}` templates — a multiline
string literal written with one backslash, mid-expression, where a
multiline literal cannot appear at all. Rewritten as the quoted format
strings they were meant to be.
Corrects one thing that predates the migration: all four bound `0.0.0.0`.
A cartridge adapter is internal and sits behind the http-capability-gateway
(ADR-0004) — the adapter READMEs say so — so all three listeners in each
now bind loopback.
Co-Authored-By: Claude Opus 5 <[email protected]>
The last two adapters each used a removed stdlib API of its own.
local-coord-mcp:
* `std.io.fixedBufferStream` is gone — `std.Io.Writer.fixed` replaces it
at 8 sites, with `.pos` becoming `.end`;
* `std.fmt.format(w, …)` folded into `Writer.print`;
* `GeneralPurposeAllocator` renamed to `DebugAllocator`;
* listener ported to `std.Io.net`. `build.zig` gains the `run`/`test`
steps it lacked (it was the one tree with no `test` step at all).
007-mcp:
* `std.process.getEnvMap` removed — reads `$OO7_WORKTREE` through the
shim's libc-backed `getenv`, so the adapter module links libc;
* `ArrayList.writer(gpa)` removed — `appendSlice`/`print` directly, and
`std.Io.Writer.Allocating` where a `*Writer` is genuinely needed;
* listener and `writeHttpResponse` ported to `std.Io.net`.
Building the 007 adapter also forced two 0.16 breakages out of
`007-mcp/ffi/oo7_mcp_ffi.zig` that the FFI's own `zig build test` never
reached, because nothing it analyses calls them:
* `std.process.Child.init`/`spawn`/`collectOutput`/`wait` folded into
`std.process.run(gpa, io, …)`, which takes the Io handle and enforces
the capture limit itself. `Term`'s tags are lower-case now and
`.signal` carries a `posix.SIG`;
* `http.Client.FetchOptions.response_storage` replaced by
`response_writer`; leaving it null discards the body, which is what
this fire-and-forget POST wanted.
Co-Authored-By: Claude Opus 5 <[email protected]>
99 `adapter/` trees existed and no job ever built one — the changed-cartridge
detector and the diff filter both globbed `*/ffi/` only, and `full-sweep`
iterated `*/ffi/build.zig`.
* the `changes` detector and the per-cartridge diff now match
`(ffi|adapter)/`, and the cartridge root is derived by stripping either
segment;
* the changed-cartridge job runs `zig build && zig build test` in
`<cart>/adapter`;
* `full-sweep` gains a second step over every `*/adapter/build.zig`,
reporting its own failure count. Its timeout goes 60 -> 120 minutes and
the changed-cartridge job's 15 -> 25 to cover the extra compiles.
`zig build` is deliberately the load-bearing adapter gate: it compiles the
executable, so `main()` and the listener paths are analysed and the step
cannot pass vacuously. `zig build test` is run too, but only 4 of 99
adapters currently declare inline tests, so on its own it would be a check
that cannot fail — the workflow header says so rather than implying
coverage that is not there.
Verified before wiring: all 99 adapters pass `zig build && zig build test`,
and all 118 `ffi/` trees still pass `zig build test`.
Co-Authored-By: Claude Opus 5 <[email protected]>
PR #114 takes the adapter layer from 3/99 to 99/99 green and wires it into CI. Three things it deliberately leaves, now visible rather than implied: - A-4 (HIGH): the 90 cloned adapters still fake dispatch — they return "<tool> forwarded" without calling boj_cartridge_invoke, contradicting the response-passthrough invariant in their own READMEs. The template was fixed properly; converting 90 is a wire-behaviour change. - A-5 (MEDIUM): adapter test coverage is 4 of 99, so `zig build test` is vacuous for 95 and `zig build` is what makes the job failable. - A-6 (LOW, FIXED): bsp/dap/lang/lsp each bound 0.0.0.0 on three listeners — 12 public ingresses against ADR-0004 and their own READMEs. Now loopback. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Note Automatic reviews are paused because your trial's included automatic processing has been used for this period. Upgrade now, or comment "Gitar review" to run a review anytime. Code Review ✅ Approved 2 resolved / 2 findingsResurrects all 99 cartridge adapters to build and test green on Zig 0.16 by fixing build APIs, string literals, and network bindings. Consider restoring concurrent connection handling and implementing multi-read request buffering in the ported three-port adapters to prevent request truncation.
✅ 2 resolved✅ Performance: Ported three-port adapters now handle connections serially
✅ Edge Case: Adapter reads request with single fillMore(); body may truncate
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Important Your trial ends in 3 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more. Was this helpful? React with 👍 / 👎 | Gitar |
|
|
✅ All code review findings resolved.
PR D of the BoJ 0.16 campaign — the last, and largest, open item
Stacked on #109. Base is
feat/zig-016-ffi-sweep, notmain, because this depends on the shim compat layer that PR introduces. Merge #109 first.The adapter layer had never compiled.
zig-test.ymlglobbed only*/ffi/, so 99 build files sat ungated since they were written, andjust mintpropagated the template's defects into every new cartridge.Result: 99/99 adapters green on
zig build && zig build test— the exact command CI now runs. Baseline was 3/99.Why they were broken — mostly not Zig 0.16
Only two of the five defect classes were version-related. The other three are why these files had never built:
\{{"success":…}}— not a token)bufPrintwithout doubling literal bracesinitsymbol absent from its own sibling FFIroot_source_filein Executable/Test options)std.net→std.Io.netCorrections to the brief I gave
k9iser-mcpwas not already-0.16-valid. Itszig build testpassed only because a test build never analysesmain();zig buildfailed onstd.net.Address. Same forbug-filing-mcp. This is whyzig build— notzig build test— is the load-bearing gate here. The same lazy-analysis blind spot hid two live 0.16 breakages in007-mcp's FFI (process.Child.init,FetchOptions.response_storage), which only surfaced when its adapter forced full analysis.local-coord's pre-existing doubled braces are legitimate format strings and were left alone.bsp,dap,langandlspbound0.0.0.0on three listeners each — 12 public ingresses. Their own READMEs and ADR-0004 state adapters are internal, loopback-only, behind thehttp-capability-gateway. They now bind loopback. Revert if that was deliberate, but it contradicted every document describing it.The template
just mintcopies it, so it got a real rebuild rather than a port. It was broken four ways — including thatdispatch()never reached the FFI at all: it matched a tool name and returned a hand-written"<tool> forwarded"string, contradicting the "response passthrough" invariant in its own README. It now dispatches throughffi.boj_cartridge_invoke. It also had zero tests, so itsteststep could not fail; it now has 5, and failability was verified by breaking an assertion and watching the step go red.What this does NOT fix — stated plainly
boj_cartridge_invokedispatch is scriptable (tool lists come fromcartridge.json) but it is a wire-behaviour change across 90 cartridges — not something to do unilaterally in a port.zig build testis vacuous for 95 of 99 adapters — only 4 declare inline tests.zig buildis what makes the job failable, and the workflow header says so rather than implying coverage that doesn't exist. I did not fabricate tests for the 95: only 56 of 94 clones even route/status, so any generated assertion would have been wrong somewhere or weakened to fit. Adapter test coverage of 4/99 is now visible debt rather than a green step hiding it.CI
zig-test.yml's detector and diff filter now match(ffi|adapter)/; the changed-cartridge job runszig build && zig build testin<cart>/adapter;full-sweepgained a second pass over every*/adapter/build.zig. Timeouts 15→25 and 60→120. The glob was wired only after its subject was green — the 99/99 sweep used the identical command.Verification (re-run independently, not taken on trust)
*/adapter/build.zig:zig build && zig build test*/ffi/build.zig:zig build testtools/sync_cartridge_shim.sh --check🤖 Generated with Claude Code