Skip to content

imcp2-deploy: publish the crate and run deploy state from the server's own lifecycle - #250

Closed
raymondk wants to merge 4 commits into
deploy-5b-hardeningfrom
deploy-5c-embedders
Closed

raymondk wants to merge 4 commits into
deploy-5b-hardeningfrom
deploy-5c-embedders

Conversation

@raymondk

Copy link
Copy Markdown
Contributor

Stacked on #249. First of four follow-ups that get the hosted deploy tools ready to be served from the gateway, which embeds the published imcp2 crate rather than running this repository's binary.

Why

Two things only work today when the server is built and run from this repository:

  • The deploy feature depends on imcp2-deploy, which is not on crates.io, so the published imcp2 cannot carry it.
  • The upload sweeper and the stop-on-shutdown signal are calls that only main.rs makes. An embedder that keeps doing what it does now (spawn_session_reaper(), shutdown()) would get neither.

What changes

  • imcp2-deploy is published, in lockstep with the other crates. imcp2 and imcp2-local name it through a workspace pin (path and version). publish-crate.yml checks its version against the tag and uploads it between imcp2-core and imcp2.
  • McpServer::spawn_session_reaper starts the deploy sweeper, once per process however many instances share the state.
  • McpServer::shutdown stops running deploys. Deploys::stop remains for a server that drains in-flight requests: called before the drain, as the bundled binary does, each deploy answers with what it created first.
  • DeployConfig documents its clamping (a zero cap is read as one, a store smaller than one archive as one archive). The library reads no environment variable; the MCP_DEPLOY_* variables stay in the bundled binary.

Before the next release tag

A trusted publisher can only be configured on a crate that exists. imcp2-deploy needs its first version published by hand and its trusted publisher configured before the first v* tag that includes this change. Otherwise the workflow uploads imcp2-core and then fails on imcp2-deploy. The workflow header says so.

Testing

  • cargo test --locked --workspace --all-targets and cargo test --locked -p imcp2 --features deploy pass; clippy is clean with and without the feature.
  • cargo publish --locked --dry-run --workspace packages and verifies all three crates in order.
  • New test the_servers_own_lifecycle_runs_the_deploy_state covers the sweeper starting once across two instances and shutdown stopping deploys.
  • Not tested: a build of the packaged imcp2 with --features deploy against the registry, which cannot resolve until imcp2-deploy is published.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV

@raymondk
raymondk requested a review from a team as a code owner November 18, 2026 21:41
Copilot AI max review requested due to automatic review settings November 18, 2026 21:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The candidate workflow and release checklist omit required coverage for imcp2-deploy, allowing a candidate to deploy successfully but fail promotion because of its stale version.

4 open issues
What changed in this PR

Prepares the hosted deploy tools for applications that embed the published imcp2 crate, including the gateway, by enabling crate publication and integrating deploy state with the server lifecycle.

Changes:

  • Makes imcp2-deploy publishable with versioned workspace dependencies and lockstep release checks.
  • Starts the shared deploy sweeper through spawn_session_reaper and signals deploys to stop through shutdown.
  • Documents embedder configuration and shutdown ordering, and adds a multi-instance lifecycle test.
File Description
src/​main.rs Delegates sweeper startup to the server lifecycle.
src/​lib.rs Integrates deploy startup and cancellation with existing lifecycle methods.
src/​deploy.rs Adds a single-start sweeper guard, lifecycle test, and configuration documentation.
README.md Explains published-feature usage and embedder shutdown ordering.
crates/​imcp2-local/​Cargo.toml Uses the shared deploy dependency declaration.
crates/​imcp2-deploy/​Cargo.toml Enables publication and adds crate metadata.
Cargo.toml Adds the versioned deploy workspace dependency.
.github/​workflows/​publish-crate.yml Extends version checks and publication guidance to include imcp2-deploy.

Review effort: Max

Comment thread .github/workflows/publish-crate.yml Resolved
Comment thread README.md Resolved
Comment thread src/deploy.rs Resolved
Comment thread src/deploy.rs Resolved
@raymondk
raymondk force-pushed the deploy-5c-embedders branch from 51d4658 to 580ca47 Compare November 18, 2026 23:50
Copilot AI max review requested due to automatic review settings November 18, 2026 23:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The publish gate leaves the hosted deploy module and its lifecycle test unchecked, while with_deploy documentation omits the stop-before-drain caveat for embedders.

2 open issues
4 resolved since last review

Review effort: Max

Comment thread .github/workflows/publish-crate.yml Resolved
Comment thread src/lib.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The shutdown documentation incorrectly guarantees that no deploy remains running, although shutdown() only signals cancellation and callers must await Deploys::stopped().

2 open issues
2 resolved since last review

Review effort: Max

Comment thread src/deploy.rs Resolved
Comment thread crates/imcp2-deploy/Cargo.toml Resolved
raymondk and others added 4 commits November 18, 2026 21:01
…loy, and run their state from the server's own lifecycle

The gateway embeds the published `imcp2` crate, so the `deploy` feature has
to work from crates.io and without the bundled binary's `main`.

- imcp2-deploy is published, in lockstep with the other crates: a crate on
  crates.io cannot depend on one that is not. `imcp2` and `imcp2-local` name
  it through a workspace pin (path and version). publish-crate.yml checks
  its version against the tag and uploads it between imcp2-core and imcp2.
  Its first version must be published by hand, and its trusted publisher
  configured, before the first tag that includes it.
- `McpServer::spawn_session_reaper` starts the deploy sweeper (once per
  process, however many instances share the state) and `McpServer::shutdown`
  stops the running deploys, so an embedder that does only what it did
  before has both. `Deploys::stop` stays for a server that drains: called
  before the drain, as the bundled binary does, each deploy answers first.
- `DeployConfig` documents what it reads a zero cap and a too-small store
  as; the library reads no environment variable.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
…se checklist, one Deploys per process, stop before the drain, and a test that counts the sweeper

- deploy-candidate.yml checks imcp2-deploy's version too, and
  CONTRIBUTING.md's release steps name its manifest and its workspace pin:
  a candidate cut by the old checklist would deploy and then fail to
  promote.
- The README and the module docs say that a process makes one `Deploys`
  and hands each server a clone, and that an embedder that drains calls
  `Deploys::stop` before the drain; the example shows the order.
- The lifecycle test counts the runtime's tasks around each
  `spawn_session_reaper`, so a second sweeper would fail it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
…deploy` says how to stop

- publish-crate.yml runs the `deploy`-feature tests on the release commit,
  as ci.yml does: the default-feature run leaves the hosted deploy module
  out.
- `McpServer::with_deploy` says what stopping asks of an embedder that
  drains — `Deploys::stop` before the drain, `Deploys::stopped` after it —
  instead of saying nothing more is needed. The README says the same, and
  that `Deploys::new` fails over a state directory in use.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
…ill said imcp2-deploy is unpublished

- `Deploys::stop` no longer says a shut-down server leaves no deploy
  running: it signals and returns, and `Deploys::stopped` is what waits.
- The crate's rustdoc said `icp-project` comes from the icp-cli repository
  and that the published `imcp2` cannot carry the feature. Neither holds,
  and it would have been published saying so. The release comments in
  imcp2-local's manifest and dist-workspace.toml name the third crate.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
@raymondk
raymondk force-pushed the deploy-5c-embedders branch from d5ab142 to 536e120 Compare November 19, 2026 02:02
Copilot AI max review requested due to automatic review settings November 19, 2026 02:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The README incorrectly describes a directory-lock startup error as data loss, and the docs.rs configuration omits the deployment API and lifecycle guidance.

2 open issues
2 resolved since last review

Review effort: Max

Comment thread Cargo.toml
[workspace.dependencies]
httpdate = "1.0.3"
imcp2-core = { path = "crates/imcp2-core", version = "0.6.1" }
imcp2-deploy = { path = "crates/imcp2-deploy", version = "0.6.1" }
Comment thread README.md
Comment on lines +641 to +642
one per server: the caps are the process's, and making a second over a
directory in use would clear the uploads and deploys of the first. Nothing
@raymondk

Copy link
Copy Markdown
Contributor Author

Superseded by the stack #254 → #259, which carries the same code in six PRs from main, with the deploy tools living in imcp2-core instead of a separate crate. The lifecycle changes are in #258; publishing a separate crate is no longer needed.

@raymondk raymondk closed this Nov 19, 2026
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.

2 participants