Skip to content

feat(mcpx): script-side generate — daemon route, TS global, op declaration (#1925 slice) - #16941

Merged
developing-today-fleet[bot] merged 1 commit into
mainfrom
lane/1222f-1925-generate
Nov 29, 2026
Merged

developing-today-fleet[bot] merged 1 commit into
mainfrom
lane/1222f-1925-generate

Conversation

@developing-today-fleet

@developing-today-fleet developing-today-fleet Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1925 — one bounded slice: the script-side generate surface, per the settled contract in pkgs/mcpx/docs/script-generate.md (#14183, closed). The #1925 track stays open for the Python/Roc bindings and any later sampling/plugin capability slice.

What lands

  • POST /v1/generate (internal/daemon/routes_generate.go): strict options validation — unknown fields, empty prompt, bad/nonpositive timeout, malformed model id, non-object schema are all rejected values (contract §6: a model-side outcome is never a throw). Resolution goes through the existing model layer with no sampling or plugin answerer installed (§3): explicit sampling/plugin selection returns unavailable, profile/auto selection never installs them as fallbacks. Per-call ask capped by profile budget then model.budget (the shared ModelTokenCap rule); deadlines take the earliest of run deadline, call timeout, and model.timeout. Provider-failure text is fixed-shape — raw provider payloads never reach a script-visible error (§6).
  • Generated client: generate() global + GenerateOptions/GenerateResult + ambient declaration (internal/codegen/emit.go). Only a missing/non-object argument throws (TypeError), per §1/§6. Python and Roc clients do not advertise generate (§2).
  • Op declaration in internal/api/ops.go, regenerating plugin/core/ops.gen.ts (dogfood copy in .opencode/plugin/core synced — all three mcpx.yml sync diffs clean) and docs/parity.md (98 ops / 77 CLI commands; mcpx generate CLI + mcpx_generate MCP tool come from the table).
  • docs/script-generate.md status updated to implemented.

Verification

Authoring worktree on the laptop, rebased onto main be0aa65945a (named fallback: laptop-local test runs in the authoring worktree, the route PR #16927 used; sandbox fleet Actions exec dispatch is on the #16824 jam):

  • go build ./... clean; go vet clean on touched packages; gofmt clean.
  • New daemon tests 7/7 pass: unavailable for provider=none and for explicit sampling; 10 rejected option shapes; a fake OpenAI-compatible endpoint answers with system-first messages and the budget cap (ask 5000 → 100) observed in the payload it received; a 500 from the endpoint classifies provider and its raw body marker does not appear in the result error; a 50 ms call timeout against a 2 s endpoint classifies timeout; the HTTP handler answers 200 with the result JSON.
  • Full internal/daemon suite pass (170 s); internal/api, internal/model, internal/refdoc, internal/settings pass; codegen TS/client/globals tests pass.
  • Two wider-tree failures are pre-existing on pristine main, reproduced on unmodified origin/main, unrelated to this diff: codegen TestRocModulePassesCompiler (Roc stdlib drift) and cli TestInlineDaemonPollIntervalChangesRetryCount.

Diff read against purpose: 9 files, +610/−12 — daemon handler + tests (new), one route line, one op entry, codegen global/declaration/client function, two generated files, two docs. No model-layer changes were needed: profiles, the routing guarantee, and typed exhaustion already landed; this slice wires the surface to them.

Lane 1222-F (delta PRESS author lane, 2026-11-29). Claim: #1925 comment 7260560797.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-29T18:52:23Z",
    "session_id": null,
    "lane": null,
    "host": "amd",
    "worktree": "/home/user/git/code-wt-1222f-1925",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/user/git/code-wt-1222f-1925",
      "repo": "developing-today/code",
      "branch": "lane/1222f-1925-generate",
      "sha": "94fed5fd2d96a8cebee73e571092015cbb1a89fc"
    },
    "auth_subject": "oc-code-05",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…ation (#1925 slice)

Implements the settled contract in pkgs/mcpx/docs/script-generate.md
(#14183) for TypeScript/JavaScript script calls:

- POST /v1/generate (internal/daemon/routes_generate.go): strict
  options validation (unknown fields, empty prompt, bad timeout,
  malformed model id, non-object schema are all `rejected` values,
  never throws); resolves the daemon's model layer with NO sampling
  or plugin answerer installed (contract section 3 — explicit
  sampling/plugin selection is `unavailable`, profile/auto selection
  never installs them); per-call ask capped by profile budget then
  model.budget via the shared ModelTokenCap rule; earliest-of
  deadlines (run, call timeout, model.timeout); results are the
  discriminated union with the section 6 errorKind taxonomy, and
  provider failure text is fixed-shape so raw provider payloads and
  credentials never leak into a script-visible error.
- Generated client: `generate()` global + GenerateOptions /
  GenerateResult types + ambient declaration (codegen/emit.go).
  Python and Roc clients do not advertise it (contract section 2).
- The `generate` operation is declared in internal/api/ops.go, which
  regenerates plugin/core/ops.gen.ts (dogfood copy synced, all three
  mcpx.yml sync diffs clean) and docs/parity.md (98 ops, 77 CLI
  commands; the generated `mcpx generate` CLI and `mcpx_generate`
  MCP tool come from the table).
- docs/script-generate.md status updated to implemented.

Verification (authoring worktree on the laptop, rebased onto main
be0aa65): go build ./... clean; go vet clean on touched packages;
new daemon tests 7/7 pass (unavailable for none/sampling, 10 rejected
shapes, provider answers with system-first messages and the budget
cap observed at the endpoint, provider failure hides the raw payload,
call timeout classifies as timeout, handler answers 200 + result
JSON); full internal/daemon suite pass (170s); internal/api,
internal/model, internal/refdoc, internal/settings, and the codegen
TS/client/globals tests pass. Two failures in the wider tree are
pre-existing on pristine main and unrelated: codegen
TestRocModulePassesCompiler (Roc stdlib drift) and cli
TestInlineDaemonPollIntervalChangesRetryCount — both reproduced on
unmodified origin/main.

Refs #1925 (one bounded slice: the track stays open for the Python
and Roc bindings and any later sampling/plugin capability slice).

Lane 1222-F (delta PRESS author lane, 2026-11-29).
@coderabbitai

coderabbitai Bot commented Nov 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 784421ca-15fc-407e-98d2-d3d155bc2efd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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.

0 participants