agent icon indicating copy to clipboard operation
agent copied to clipboard

Windows: ownership record without process birth evidence permanently blocks serve startup

Open Xxx91n opened this issue 1 month ago • 1 comments

Summary

On Windows 0.39.3, a serve run whose self birth-evidence probe times out still starts, but persists runtime.owner/owner.json (and server.pid) without processIdentity. The next launch then fails closed in ~3.3s with only a redacted Server error: <private> line, and every subsequent launch fails until the ownership metadata is manually removed.

This is a distinct continuation of #564 (closed). The earlier diagnosis attributed the crash to the 3s probe throwing. Reproduction shows the probe timeout itself does not throw; it creates a legacy-shaped record that poisons the next claim.

Related field report: https://github.com/1mcp-app/agent/issues/564#issuecomment-6235572310

Environment

  • Windows 11 Pro 10.0.26100 x64
  • C:\tools\1mcp\1mcp-win32-x64.exe 0.39.3 (SEA)
  • Real 13-upstream config, minimized to {"mcpServers":{}} for identity-only reproduction
  • PowerShell 7.4.17; powershell.exe probe measured 1.99–3.13s per call

Reproduction

  1. Start serve with an isolated --config-dir. Under load the self probe times out; the server still starts, but owner.json / server.pid have no processIdentity and no explicit degradation marker.
  2. Stop the process. Copy the scope state to an isolated directory.
  3. Run the same serve command: exit 1 after ~3.3s; stdout only Server error: <private>; stderr empty on 0.39.3; owner.json retained.
  4. Rename owner.json inside the directory: still exit 1 (ambiguous: directory contains an unexpected entry).
  5. Delete owner.json but keep the empty directory: still exit 1 (incomplete/unknown files).

Additional evidence:

  • CPU-stress run: self probe ETIMEDOUT at 3140/3141ms; startup still succeeded and wrote a record without identity.
  • serve --status on the stale scope now reports not running rather than an identity error.

Root cause

  1. processIdentity.ts returns undefined on probe timeout; claimRuntimeScope and writePidFile still persist the record (JSON drops the key).
  2. inspectIdentity returned unknown for missing evidence without checking whether the PID existed; ownerIsDead only reclaims on dead.
  3. The next claim therefore treats a provably dead owner as an active owner and fails closed. The failure happens before the file logger attaches and is fully redacted by the privacy rules.
  4. An empty or unknown-entry ownership directory is also permanently ambiguous.

Proposed fix

  • Treat missing evidence plus a provably absent PID as dead for reclaim and read paths; keep termination and worker authorization strict (ADR 0017 addendum).
  • Persist explicit identityEvidence: { status: "unavailable", code, elapsedMs, at } instead of a silent legacy-shaped record; reuse the claim's single probe for the PID file; start immediately and repair the same PID + claim-ID generation in the background (10s first, exponential to a 60s cap, five attempts).
  • Reclaim empty canonical ownership directories under the scope lock; keep unknown entries fail-closed and name them.
  • Add closed-enum claim-failure diagnostics (ownership_reason, evidence_status, acquisition_code, elapsed_ms), fd-2 output, and a last-resort --log-file line.

Acceptance

  • [ ] The poisoned scope (identity-less owner + dead PID) starts.
  • [ ] An empty owner directory starts.
  • [ ] Unknown entries fail closed and name the entries.
  • [ ] A timed-out claim starts with explicit unavailable evidence and self-repairs.
  • [ ] Termination and worker authorization still require birth evidence.
  • [ ] Unit, integration, and Windows artifact fixtures pass; unavailable gates are reported, not waived.

Xxx91n avatar Oct 22 '26 19:10 Xxx91n

Verified on the reporting machine: the CI-built binary starts the previously bricked Runtime Scope

Tested 2026-10-23 on Windows 11 10.0.26100 x64, using the packaged Windows SEA binary built by the fork's CI/CD. All paths, host names, and claim IDs below are desensitized.

Provenance (traceable)

Item Value
Upstream PR #686
PR branch Xxx91n/agent → fix/runtime-ownership-evidence-recovery
PR head commit (source tree tested) 398431c7a836858c046f83a78f4c1a6ff453a24b
CI build branch Xxx91n/agent → ci/windows-exe-artifact @ 720fbbdb8f01275cd2154d0d1bae6a82e47f81ad
Parent of build commit 398431c7a836858c046f83a78f4c1a6ff453a24b (i.e. exactly the PR head)
Only difference vs PR head .github/workflows/build-binaries.yml (+6/−21): a build_ref dispatch input, a Windows-only matrix, and dropping the release job environment
Build run https://github.com/Xxx91n/agent/actions/runs/39941544132 (Binaries, windows-latest / win32-x64, success)
Artifact 1mcp-win32-x64.exe (zip 42,498,590 B → exe 115,593,728 B)
Version reported by the artifact 0.39.2 — the repository version, deliberately not bumped
Replaced target C:\tools\1mcp\1mcp-win32-x64.exe
Start method Windows Task Scheduler task \1mcp-daemon (schtasks /run), not a manual invocation

Because the built commit's parent is the PR head and the only changed file is a workflow definition, the tested binary contains the same src/ tree as #686 head.

Before — installed 0.39.3 against the real scope

The Runtime Scope still held the original evidence-less record:

%APPDATA%\1mcp\runtime.owner\owner.json
{"version":1,"pid":6408,"claimId":"<claimId>","kind":"foreground-http","claimedAt":"2026-10-17T06:28:29.724Z"}

PID 6408 had been gone for days, yet both read and write paths refused to proceed:

$ 1mcp-win32-x64.exe serve --status      # 0.39.3
Runtime Scope: %APPDATA%\1mcp
Status: error
Error: Cannot verify process identity for PID 6408: the record has no process birth evidence (legacy format).
Lifecycle metadata was retained. ...
$ 1mcp-win32-x64.exe serve               # 0.39.3
[ERROR] message="Server error: <private>" event="serve.server.error.a68bf449" error_kind="other" error_code="other"
exit=1

This is the reported brick: the stale record could not be reclaimed and the runtime could not start.

After — CI artifact from 398431c, started through the scheduled task

schtasks /run /tn "\1mcp-daemon" launched the runtime and it came up normally:

2026-10-23T11:00:04.359Z [INFO] Async server setup completed - HTTP server ready, MCP servers loading in background
2026-10-23T11:00:04.602Z [INFO] PID file written: <private> {"event":"pidFileManager.pid.file.written.41a5471a"}

Lifecycle metadata was reclaimed and rewritten with kernel evidence:

%APPDATA%\1mcp\runtime.owner\owner.json
{"version":1,"pid":15476,"claimId":"<claimId>","kind":"foreground-http","claimedAt":"2026-10-23T10:59:59.577Z",
 "processIdentity":{"platform":"win32","hostname":"<hostname>","startTime":"639283499986047698"}}
%APPDATA%\1mcp\server.pid
{ "pid": 15476,
  "processIdentity": { "platform": "win32", "hostname": "<hostname>", "startTime": "639283499986047698" },
  "url": "http://127.0.0.1:3050/mcp", "port": 3050, "host": "127.0.0.1", "transport": "http",
  "startedAt": "2026-10-23T11:00:04.598Z", "configDir": "%APPDATA%\\1mcp",
  "logFile": "%APPDATA%\\1mcp\\logs\\server.log" }
$ 1mcp-win32-x64.exe serve --status      # new artifact
Runtime Scope: %APPDATA%\1mcp
Status: running (ready)
PID: 15476
URL: http://127.0.0.1:3050/mcp
Started: 2026-10-23T11:00:04.598Z
Log file: %APPDATA%\1mcp\logs\server.log
Identity evidence: kernel
Process: alive
Readiness (/health/ready): ready
exit=0
GET /health    → {"status":"healthy","version":"0.39.2","servers":{"total":12,"healthy":12,"unhealthy":0}, ...}
GET /health/ready → {"status":"ready", ...}

schtasks /query /tn "\1mcp-daemon"  → Status: Running   (task PID 15476 matches the record)

One residual behaviour worth recording

The very first serve --status was run while other processes were loading the box, and the PowerShell birth-evidence probe exceeded its 3-second budget twice — including the probe of the CLI's own PID, so the read-only command reported an evidence unknown instead of a state:

[WARN] message="Process birth evidence acquisition failed" event="processIdentity.acquisition-failed"
       platform="win32" pid=<cli-pid> elapsedMs=3039 code="ETIMEDOUT"
[WARN] message="Process birth evidence acquisition failed" event="processIdentity.acquisition-failed"
       platform="win32" pid=<cli-pid> elapsedMs=3036 code="ETIMEDOUT"
Runtime Scope: %APPDATA%\1mcp
Status: error
Error: Cannot verify process identity for PID 15476: OS process evidence is unavailable to this CLI
       (permissions or platform tools) (platform=win32, lookup PID=<cli-pid>, elapsedMs=3036,
       code=ETIMEDOUT; retry after reducing system load). Lifecycle metadata was retained. ...

Re-run when idle, the same command returned running (ready) / Identity evidence: kernel / exit 0 as above, the runtime kept serving traffic throughout, and nothing was lost: the failure is a diagnostic conservative answer, not a startup block, and the record was never demoted. Note the contrast with 0.39.3: the timeout now only degrades a single read command, whereas before it made the scope permanently unstartable.

Conclusion

The packaged binary built from PR #686 head (398431c) starts the Runtime Scope that 0.39.3 could not start, reclaims the evidence-less record, records kernel evidence, and reports running (ready); the scheduled-task launch path works unchanged. Remaining known limitation on this host is the 3s PowerShell probe latency under load, which now surfaces as a bounded, retryable diagnostic rather than a brick.

Xxx91n avatar Oct 23 '26 11:10 Xxx91n