Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
69167b5
feat(mcp): introduce isolated transactional upstream reload runtime
AKzar1el Nov 19, 2026
7feef36
refactor(mcp): own upstream services by immutable connection generation
AKzar1el Nov 19, 2026
6529804
fix(mcp): expose generation call lease within internal catalog
AKzar1el Nov 19, 2026
529c728
fix(mcp): share generation type with catalog router
AKzar1el Nov 19, 2026
b82396b
feat(mcp): pin catalog calls to their source generation
AKzar1el Nov 19, 2026
68beb01
feat(mcp): dispatch across atomic reloadable tool snapshots
AKzar1el Nov 19, 2026
405de74
fix(mcp): count reloadable bridge tools correctly in server banner
AKzar1el Nov 19, 2026
bb49f57
refactor(mcp): enforce per-source reload leases and remove unused state
AKzar1el Nov 19, 2026
3ce2d61
refactor(mcp): align generation construction with minimal state
AKzar1el Nov 19, 2026
43fcde4
test(mcp): exercise real upstream swapping, pinned calls, rollback an…
AKzar1el Nov 19, 2026
93ee0f8
test(mcp): enable isolated reload integration fixtures
AKzar1el Nov 19, 2026
755cb02
fix(mcp): make reload initialization future Send and update legacy as…
AKzar1el Nov 19, 2026
1034a6c
docs(mcp): document transactional reload behavior, limits and gated d…
AKzar1el Nov 19, 2026
09dcce8
test(mcp): expose immutable source snapshot to integration assertions
AKzar1el Nov 19, 2026
62f12eb
fix(mcp): keep direct and catalog tool registry unique across sources
AKzar1el Nov 19, 2026
c3fdffc
test(mcp): cover catalog/gateway rediscovery, reconnect, cancellation…
AKzar1el Nov 19, 2026
138abc1
style(mcp): apply rustfmt fixes confirmed by CI (src/bridge/hot_reloa…
AKzar1el Nov 19, 2026
cc4dcd4
style(mcp): apply rustfmt fixes confirmed by CI (src/bridge.rs)
AKzar1el Nov 19, 2026
8f0ee09
style(mcp): apply rustfmt fixes confirmed by CI (src/server.rs)
AKzar1el Nov 19, 2026
9c48bc8
fix(mcp): return structured failure and retained-generation diagnostics
AKzar1el Nov 19, 2026
cfbc295
docs(mcp): correct operator guide Markdown code spans
AKzar1el Nov 19, 2026
8281331
feat(mcp): expose reload phase timings and remaining in-flight calls
AKzar1el Nov 19, 2026
9c5367e
refactor(mcp): use one conversion for gateway function descriptors
AKzar1el Nov 19, 2026
8987a6c
refactor(mcp): reuse gateway metadata conversion on reload
AKzar1el Nov 19, 2026
f10b504
fix(mcp): honor cancellation after readiness but before registry publ…
AKzar1el Nov 19, 2026
f3d74c1
fix(mcp): release startup bridge tool snapshot to retire old processes
AKzar1el Nov 19, 2026
63d3257
test(mcp): assert drained generations and services are not retained
AKzar1el Nov 19, 2026
abd0697
docs(mcp): record phase timings and cross-generation resource-link ca…
AKzar1el Nov 19, 2026
49d93e3
style(mcp): apply CI rustfmt corrections in src/bridge/hot_reload_tes…
AKzar1el Nov 19, 2026
d5feede
style(mcp): apply CI rustfmt corrections in src/bridge.rs
AKzar1el Nov 19, 2026
3acf5cd
refactor(mcp): share individual dynamic tools independently of regist…
AKzar1el Nov 19, 2026
998130a
fix(mcp): store validated MCP tool descriptors as independently pinne…
AKzar1el Nov 19, 2026
8556193
fix(mcp): dispatch pins only the selected upstream generation to prev…
AKzar1el Nov 19, 2026
040e5e2
fix(mcp): propagate trait-object dispatch references after source-spe…
AKzar1el Nov 19, 2026
84a081d
fix(mcp): use trait object in owner-chat cleanup gate
AKzar1el Nov 19, 2026
15e0a99
test(mcp): verify unrelated long-running request cannot pin old sourc…
AKzar1el Nov 19, 2026
c89ee10
docs(mcp): clarify source-specific dispatch pinning and retirement
AKzar1el Nov 19, 2026
da24d1a
style(mcp): apply remaining format hints (src/bridge/hot_reload.rs)
AKzar1el Nov 19, 2026
a869594
style(mcp): apply remaining format hints (src/bridge.rs)
AKzar1el Nov 19, 2026
115576b
fix(mcp): report retained old source generations accurately after drain
AKzar1el Nov 19, 2026
f27c9bf
docs(mcp): describe per-tool dispatch ownership and honest draining r…
AKzar1el Nov 19, 2026
402c1bf
fix(mcp): remove duplicate stderr module and format bridge generation
AKzar1el Nov 19, 2026
bfb4ea2
style(mcp): apply CI rustfmt changes to live hot reload tests
AKzar1el Nov 19, 2026
a0c72d3
fix(mcp): satisfy strict Clippy in per-source dispatch fallback
AKzar1el Nov 19, 2026
cc92b3d
fix(mcp): preserve safe startup report wording for catalog and unsupp…
AKzar1el Nov 19, 2026
8833c5d
fix(mcp): register drain waiter before reading in-flight count
AKzar1el Nov 19, 2026
c85264f
style(mcp): apply exact rustfmt fix to unsupported-transport report
AKzar1el Nov 19, 2026
8a1540e
test(mcp): add isolated real stdio fixture with distinct process iden…
AKzar1el Nov 19, 2026
d2c4f64
test(mcp): verify real stdio process replacement, drain and rollback …
AKzar1el Nov 19, 2026
133b0e2
test(mcp): run isolated stdio process reload in Windows and macOS ser…
AKzar1el Nov 19, 2026
17b0d31
test(mcp): verify retired stdio OS child exits and apply CI rustfmt
AKzar1el Nov 19, 2026
4df4f73
test(mcp): cover real GodPrompt 1.0.3 to 1.1.1 reload and rollback
AKzar1el Nov 20, 2026
39c2189
ci(mcp): run isolated real GodPrompt npm version switch as required gate
AKzar1el Nov 20, 2026
eb029f3
style(mcp): apply exact Rustfmt spacing in GodPrompt canary
AKzar1el Nov 20, 2026
91cd90b
style(mcp): satisfy strict Clippy in real GodPrompt canary
AKzar1el Nov 20, 2026
d91e73d
ci: build isolated Windows hot reload preview artifact without deploy…
AKzar1el Nov 20, 2026
e0670de
test(mcp): allow Windows runner stdio startup under resource contention
AKzar1el Nov 20, 2026
ce590c5
fix(mcp): parse and validate existing browser Send gate config in pre…
AKzar1el Nov 20, 2026
29650c5
fix(mcp): preserve existing Send-gate environment for browser companion
AKzar1el Nov 20, 2026
85a6608
ci(mcp): rebuild Windows preview when browser Send-gate compatibility…
AKzar1el Nov 20, 2026
8c30540
style(mcp): apply CI Rustfmt for browser Send-gate compatibility
AKzar1el Nov 20, 2026
29d4b37
docs(mcp): clarify exact config source keys for hot reload
AKzar1el Nov 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ jobs:
- name: Test
run: cargo test --all

- name: Test actual GodPrompt 1.0.3 to 1.1.1 hot reload and rollback
env:
CODEXIFY_CANARY_OLD_GODPROMPT: ${{ runner.temp }}/godprompt-old/node_modules/god-prompt-mcp/dist/stdio.js
CODEXIFY_CANARY_NEW_GODPROMPT: ${{ runner.temp }}/godprompt-new/node_modules/god-prompt-mcp/dist/stdio.js
run: |
npm install --prefix "$RUNNER_TEMP/godprompt-old" --no-save --no-package-lock --ignore-scripts --no-audit --no-fund god-prompt-mcp@1.0.3
npm install --prefix "$RUNNER_TEMP/godprompt-new" --no-save --no-package-lock --ignore-scripts --no-audit --no-fund god-prompt-mcp@1.1.1
test -f "$CODEXIFY_CANARY_OLD_GODPROMPT"
test -f "$CODEXIFY_CANARY_NEW_GODPROMPT"
cargo test --locked --lib service_local_godprompt_candidate_upgrade_and_failed_rollback -- --nocapture

- name: Test Rust and TypeScript browser companion contract
env:
CODEXIFY_TEST_BROWSER_COMPANION_BUN: ${{ steps.browser-bun.outputs.bun-path }}
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/preview-hot-reload-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build experimental Codexify hot reload for Windows

on:
push:
branches:
- feat/per-mcp-hot-reload-20261119
paths:
- .github/workflows/preview-hot-reload-windows.yml
- src/markdown_chat/mod.rs
- src/agent_automation/install.rs

permissions:
contents: read

jobs:
preview-windows:
name: Package pinned Windows feature binary
runs-on: windows-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build from exact branch commit
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
cargo build --release --locked --bin codexify
if ($LASTEXITCODE -ne 0) { throw 'Cargo build failed' }
$out = Join-Path $env:RUNNER_TEMP 'codexify-hot-reload-preview'
New-Item -ItemType Directory -Force -Path $out | Out-Null
$binary = Join-Path (Get-Location) 'target\release\codexify.exe'
if (!(Test-Path -LiteralPath $binary -PathType Leaf)) { throw 'Expected executable missing' }
Copy-Item -LiteralPath $binary -Destination (Join-Path $out 'codexify.exe')
& (Join-Path $out 'codexify.exe') --help | Out-Null
if ($LASTEXITCODE -ne 0) { throw 'Preview binary self-probe failed' }
$hash = (Get-FileHash -LiteralPath (Join-Path $out 'codexify.exe') -Algorithm SHA256).Hash.ToLowerInvariant()
Set-Content -LiteralPath (Join-Path $out 'SHA256SUMS.txt') -Value ("$hash codexify.exe") -Encoding ascii
Set-Content -LiteralPath (Join-Path $out 'SOURCE_COMMIT.txt') -Value "${{ github.sha }}" -Encoding ascii
Set-Content -LiteralPath (Join-Path $out 'PREVIEW_NOTICE.txt') -Value 'EXPERIMENTAL binary from feature branch PR #11. Not an official release. Activate only after backing up the existing executable; coordinate with other Codexify workers.' -Encoding ascii
- uses: actions/upload-artifact@v4
with:
name: codexify-pr11-windows-preview
path: ${{ runner.temp }}/codexify-hot-reload-preview/*
if-no-files-found: error
retention-days: 7
123 changes: 123 additions & 0 deletions docs/MCP_HOT_RELOAD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Per-source MCP hot reload (operator guide)

**Status:** experimental, opt-in through a staged build. This document describes
source behavior, not a deployed feature. Do not replace an active Codexify
service without separate approval and validation.

## Scope

`reload_mcp` reloads exactly one existing upstream source. Its `source`
argument must match the **exact configured MCP server key** from the resolved
`mcpServers` configuration (including inherited Codex MCP sources). For example,
if the configured key is `god-prompt-mcp`, call
`{"source":"god-prompt-mcp"}`. Do not substitute a normalized catalog source ID
such as `god_prompt_mcp` from `mcp_list_sources`: it is not necessarily the
configuration key and can return `SOURCE_UNKNOWN` without changing the running
connection. The call cannot supply a command, executable, working directory,
URL, environment variables, or credentials.

The server rereads its operator configuration (including inherited Codex MCP
sources) **read-only** using its startup CLI selection. A target that was
removed or disabled fails closed. No global service restart, tunnel reconnect,
task replacement, or unrelated source reconnection is part of this operation.

The replacement uses the existing MCP transport implementation for **stdio**
and **Streamable HTTP**. Unsupported legacy SSE and WebSocket sources remain
unsupported; the operation never silently falls back to a process-wide restart.

## Lifecycle and safety

1. The scoped reload lock rejects concurrent attempts for the same source
(`RELOAD_IN_PROGRESS`); unrelated source reloads can progress concurrently.
2. The updated source specification is validated, started, initialized, and
queried with `tools/list`. A bounded MCP ping must also receive a
successful response or a protocol-level MCP error indicating a live peer.
3. The new tool definitions are validated and an immutable registry view is
constructed. The new view replaces the old view in one atomic pointer swap.
Concurrent distinct-source reloads rebuild against the latest view.
4. Each dispatch retains only its selected validated upstream tool and that
source's connection generation. Write-capable calls are **never replayed**;
unrelated direct/gateway sources are not retained by a long-running call.
Cancellation and timeout semantics remain those of the forwarded request.
5. The old generation is released when no selected old tool or catalog
snapshot retains it. The operation reports whether forwarded calls drained
within the source's configured `requestLimits.slowCancellationMs` interval.
The separate `oldGenerationStillReferenced` flag covers retained references
even when no forwarded calls remain. A drain timeout does **not** kill or
replay an in-progress side-effecting call.
6. On failure **before** the swap, the new candidate is dropped and the old
view is never replaced. Errors use bounded diagnostic codes and do not
echo credentials, command lines, headers, environment variables, or raw
tool-response bodies.

For stdio, the spawned Tokio child has `kill_on_drop` enabled, so aborted
initializations should not leave the candidate running. A platform-specific
Windows child-lifecycle integration and repeated process-tree soak remain
required acceptance gates before production activation.

## Result and tool discovery

A successful result includes `source`, `outcome`,
`previousGeneration`, `replacementGeneration`, old/new reported MCP
server versions, readiness, counts of added/removed/changed/unchanged
tool definitions, `oldCallsDrained`, `oldCallsStillRunning`,
`oldGenerationStillReferenced`, `oldGenerationRetiring`, `rollback`,
`diagnosticCode`, and measured
`timingsMs` for initialization/readiness, registry switch, draining and total
reload duration.

The source's discovery data and forwarded-call routes change together in the
server's tool registry. Existing transport sessions can observe changed
definitions on **another `tools/list`** request. **An already-open ChatGPT
chat is not guaranteed to receive new tool definitions automatically.**
Its connector may need Refresh, reconnection or a new conversation before
new direct tools appear. The result explicitly sets
`clientRediscoveryRequired: true`.

Catalog-mode source and tool identifiers remain generated by the existing
catalog and may change when a source's tool set changes. Re-query
`mcp_list_sources`, `mcp_search_tools`, and `mcp_get_tool` before calling
a new or modified tool. Gateway clients must refresh their advertised schema
and generated skill after reload.

## Failure and boundary conditions

- `SOURCE_UNKNOWN` / `SOURCE_REMOVED` / `SOURCE_DISABLED`: verify the
exact configured MCP key, not a normalized catalog ID. Do not spawn an
arbitrary process or reinterpret the input as a path.
- `RELOAD_IN_PROGRESS`: no duplicate replacement of the same source.
- `CONFIG_INVALID`, `CONFIG_CLI_INVALID`, `INITIALIZE_FAILED`,
`READINESS_FAILED`: old healthy generation is retained.
- `TOOL_NAME_LIMIT`: bound on unique registered direct/gateway tool names;
the attempted registry swap is discarded.
- `CANCELLED`: an aborted preparation does not switch generations.
- If the old generation became unhealthy independently, a successful new
connection is preferred; the operation does not imply that the old peer can
be resurrected.
- Resource links issued before a reload are separate capabilities. An upstream
resource fetched **after** its old connection retires can fail; request a
fresh resource link from the new source. Already-running resource reads
retain their own peer and cancellation semantics, but cross-generation
resource-link durability is not claimed by this implementation.
- Invalid data from upstream tool descriptions must remain untrusted.
Reload permission uses existing Codexify connector authorization and audit
boundaries. Do not expose the control plane to unauthenticated clients.

## Verification gate

The following must pass on the **exact candidate commit** before any
deployment: Rust formatting and compilation, strict lint, full Rust suite,
downstream HTTP MCP handshake, selected-source version and tool-diff checks,
two independent unrelated MCP sources, read/write in-flight calls, duplicate
reload and failure injection, cleanup/leak soak, and Windows native-process
termination. Reproduce an isolated old-to-new GodPrompt candidate switch
without touching the running GodPrompt instance; verify new version and
rollback. Measure switchover, drain and end-to-end request latency using a
repeatable workload. Do not report "zero downtime" without observed proof.

**Not included:** automatic filesystem watching. It remains disabled rather
than introducing unverified debouncing and partially written config races.

This feature does not merge the separate Windows scheduled-supervisor orphan
cleanup branch. Keep that work independent and verify its eventual integration
before any production cutover.
49 changes: 49 additions & 0 deletions scripts/fixtures/hot-reload-stdio-mcp.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// No dependencies or network: isolated MCP stdio child for Rust hot-reload tests.
// Every invocation is a separate operating-system process.
import { createInterface } from 'node:readline';
import { writeFileSync } from 'node:fs';

const version = process.argv[2] ?? 'old';
const pid = process.pid;
const input = createInterface({ input: process.stdin, crlfDelay: Infinity });

function respond(id, result) {
process.stdout.write(JSON.stringify({ jsonrpc: '2.0', id, result }) + '\n');
}
function tool(name, description) {
return { name, description, inputSchema: { type: 'object', properties: {}, additionalProperties: false } };
}
function replyToTool(id) {
respond(id, { content: [{ type: 'text', text: version + ':' + pid }], isError: false });
}

for await (const line of input) {
let request;
try { request = JSON.parse(line); } catch { continue; }
if (!request || !Object.hasOwn(request, 'id')) continue;
const { id, method } = request;
if (method === 'initialize') {
respond(id, {
protocolVersion: request.params?.protocolVersion ?? '2025-03-26',
capabilities: { tools: {} },
serverInfo: { name: 'isolated-hot-reload-stdio-fixture', version },
});
} else if (method === 'tools/list') {
const tools = [tool('probe', 'Version probe ' + version), tool('slow', 'Slow probe ' + version)];
if (version === 'new') tools.push(tool('new_tool', 'New tool in replacement generation'));
respond(id, { tools });
} else if (method === 'tools/call') {
if (request.params?.name === 'slow') {
if (process.env.HOT_RELOAD_SLOW_MARKER_FILE) {
writeFileSync(process.env.HOT_RELOAD_SLOW_MARKER_FILE, String(pid));
}
setTimeout(() => replyToTool(id), 300);
} else {
replyToTool(id);
}
} else if (method === 'ping') {
respond(id, {});
} else {
process.stdout.write(JSON.stringify({ jsonrpc: '2.0', id, error: { code: -32601, message: 'Method not found' } }) + '\n');
}
}
3 changes: 3 additions & 0 deletions src/agent_automation/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ impl BrowserCompanionManager {
.stdin(Stdio::null())
.stdout(Stdio::from(log))
.stderr(Stdio::from(stderr));
if let Some(path) = &self.config.provider_send_gate_path {
command.env("CODEXIFY_BROWSER_SEND_GATE_PATH", path);
}
configure_detached_process(&mut command);
let mut child = command
.spawn()
Expand Down
Loading
Loading