Skip to content

codedb_remote: forward pagination/read params + add 'read' action#340

Merged
justrach merged 2 commits intorelease/0.2.579from
improve/codedb-remote
Apr 26, 2026
Merged

codedb_remote: forward pagination/read params + add 'read' action#340
justrach merged 2 commits intorelease/0.2.579from
improve/codedb-remote

Conversation

@justrach
Copy link
Copy Markdown
Owner

Summary

  • Schema now advertises every action × backend the implementation actually accepts (was missing read and 7 new params), plus path/lines for the new read action and limit/offset/prefix/expand/since for paginated actions.
  • handleRemote collapsed from two ~100-line branches into a single shared path that builds a curl --data-urlencode arg list via a small fetchRemote helper. Every existing error message is preserved verbatim.
  • Optional pagination params are forwarded transparently — when the server adds support (codegraff fix tracked in codedb_remote: tree/commits/dep-history overflow MCP token limits — add pagination #332), callers see slicing without another client release.

Addresses #335 (schema underadvertising), partially addresses #332 (forwarding side; server-side pagination still needed) and #333 (read plumbing; server-side endpoint still needed).

Test plan

  • zig build — clean
  • zig build test — 407/408 pass (the one failing test, mcp.test.issue-258, fails identically on base; unrelated cache path-validation issue)
  • Manual: call codedb_remote action=read path=src/foo.zig against a slug and confirm clear 404 error from the codegraff worker (until codedb_remote: add 'read' action — locate-but-can't-view gap #333 lands)
  • Manual: call codedb_remote action=tree limit=50 prefix=src/ and confirm the URL we issue includes both limit=50 and prefix=src/ query params (server may ignore for now)

🤖 Generated with Claude Code

Add an explicit `read` action on the codegraff backend (server-side
support tracked in #333) plus per-action optional URL params so big
responses can be sliced server-side as the cloud catches up:

- tree: forward limit/offset/prefix/expand
- commits, dep-history: forward limit/since
- read: forward path (required) and lines

Refactor handleRemote so a single fetchRemote helper builds the curl
argv (with one --data-urlencode per param). Cuts the duplicated
codegraff-vs-wiki branches from ~210 lines to one shared path while
preserving every existing error message verbatim.

Schema now advertises read + the new params + scope/backend so callers
can discover the matrix without reading source.

Refs #332 #333 #335

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Benchmark Regression Report

Thresholds: 10.00% and 50,000 ns absolute delta

NOISE means the percentage threshold was exceeded, but the absolute delta was too small to fail CI.

Tool Base (ns) Head (ns) Delta Abs Delta (ns) Status
codedb_bundle 492245 511173 +3.85% +18928 OK
codedb_changes 53604 60363 +12.61% +6759 NOISE
codedb_deps 9176 8802 -4.08% -374 OK
codedb_edit 5300 20787 +292.21% +15487 NOISE
codedb_find 60191 64342 +6.90% +4151 OK
codedb_hot 93834 99611 +6.16% +5777 OK
codedb_outline 261454 279355 +6.85% +17901 OK
codedb_read 86316 85264 -1.22% -1052 OK
codedb_search 176091 187735 +6.61% +11644 OK
codedb_snapshot 249964 247778 -0.87% -2186 OK
codedb_status 211854 213896 +0.96% +2042 OK
codedb_symbol 60583 64814 +6.98% +4231 OK
codedb_tree 41527 42701 +2.83% +1174 OK
codedb_word 67045 76640 +14.31% +9595 NOISE

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4bb5fd076a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/mcp.zig
Comment on lines +1684 to +1685
if (getBool(args, "expand")) {
params.append(alloc, .{ .name = "expand", .value = "true" }) catch {};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Forward explicit expand=false for tree requests

The new expand option is documented as a boolean where false requests a compact directory summary, but this branch only appends the query parameter when getBool(args, "expand") is true. Because missing and explicit false are treated the same, callers cannot actually send expand=false, so codedb_remote action=tree cannot request the compact mode and may still return large full-tree payloads.

Useful? React with 👍 / 👎.

Drop -sf in favor of -s + curl -w '%{http_code}' so non-2xx responses
come through with their body and the actual status. fetchRemote now
parses a [CODEDB-STATUS] sentinel from the trailing curl output and
returns {captured, status, body_len}.

handleRemote treats 200-299 as success; anything else formats as
"error: <host> HTTP <code> for <slug>/<action> — <body>". Body text is
truncated to 200 chars; falls back to stderr if body is empty.

Closes #334. Also self-diagnoses #338: previously opaque "outline
returned error" now reads "HTTP 404 — {\"error\":\"No outline
section\"}", making it obvious the snapshot just lacks outline data.

Refs #334 #338

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Benchmark Regression Report

Thresholds: 10.00% and 50,000 ns absolute delta

NOISE means the percentage threshold was exceeded, but the absolute delta was too small to fail CI.

Tool Base (ns) Head (ns) Delta Abs Delta (ns) Status
codedb_bundle 524181 511831 -2.36% -12350 OK
codedb_changes 62082 54298 -12.54% -7784 OK
codedb_deps 9301 9317 +0.17% +16 OK
codedb_edit 6714 6333 -5.67% -381 OK
codedb_find 65123 62837 -3.51% -2286 OK
codedb_hot 97978 98835 +0.87% +857 OK
codedb_outline 269271 263830 -2.02% -5441 OK
codedb_read 94508 88215 -6.66% -6293 OK
codedb_search 178550 177346 -0.67% -1204 OK
codedb_snapshot 268393 262745 -2.10% -5648 OK
codedb_status 221545 215313 -2.81% -6232 OK
codedb_symbol 60564 58805 -2.90% -1759 OK
codedb_tree 41863 43263 +3.34% +1400 OK
codedb_word 68477 71272 +4.08% +2795 OK

@justrach justrach merged commit 256082b into release/0.2.579 Apr 26, 2026
1 check passed
@justrach justrach deleted the improve/codedb-remote branch April 27, 2026 09:23
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.

1 participant