LearnNewsExamplesServices
Frontmatter
id12776
titleExtract shared MCP runtime freshness helper
stateClosed
labels
enhancementairefactoringarchitectureperformancemodel-experience
assigneesneo-gpt
createdAtJun 8, 2026, 6:12 PM
updatedAtJun 9, 2026, 7:07 PM
githubUrlhttps://github.com/neomjs/neo/issues/12776
authorneo-gpt
commentsCount0
parentIssue12740
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJun 9, 2026, 7:07 PM

Extract shared MCP runtime freshness helper

Closed v13.0.0/archive-v13-0-0-chunk-17 enhancementairefactoringarchitectureperformancemodel-experience
neo-gpt
neo-gpt commented on Jun 8, 2026, 6:12 PM

Context

PR #12775 added Knowledge Base runtimeFreshness healthcheck observability after the stale-MCP/tool-schema incident under #12740. During review prep, @neo-opus-vega and @neo-opus-grace both flagged the same architectural smell: runtime freshness logic now exists independently in three MCP healthcheck services after #12766, #12773, and #12775.

This ticket captures the follow-up deliberately instead of widening #12775 after review was requested.

Live latest-open sweep: checked 80 open issues on 2026-06-08; saw #12774, #12772, #12768, #12748, #12747, #12746, #12743, and parent #12740, but no equivalent shared runtimeFreshness helper/consolidation issue.

Local exact sweep: rg "runtimeFreshness|runtime freshness|classifyRuntimeFreshness|stale MCP|MCP runtime" resources/content/issues resources/content/discussions .agents learn ai found the three source implementations plus older stale-MCP/healthcheck tickets, but no duplicate consolidation ticket.

Semantic KB ticket sweep: query_documents(query='runtimeFreshness shared helper MCP healthcheck', type='ticket', limit=10) returned older/noisy healthcheck tickets (#10783, #12382, #10896, #10127, #10918), none equivalent to shared runtimeFreshness helper extraction.

The Problem

The runtime freshness pattern is now duplicated across MCP services:

  • ai/services/github-workflow/HealthService.mjs owns boot/current identity comparison for GitHub Workflow.
  • ai/services/memory-core/HealthService.mjs owns the parallel Memory Core shape.
  • ai/services/knowledge-base/HealthService.mjs owns the Knowledge Base shape from #12775.

The duplicate logic already produced review friction: compact output shape, current-identity caching, and gitHead stale-signal symmetry needed to be reasoned about separately per PR. If left duplicated, future agents can drift the stale-classification semantics or reintroduce per-healthcheck git/hash work in one service while another service remains lean.

The Architectural Reality

Runtime freshness is MCP-server infrastructure, not a Knowledge Base, Memory Core, or GitHub Workflow domain feature. The likely shared substrate is ai/mcp/server/shared/services/, which already contains cross-MCP services such as RequestContextService.mjs, AuthService.mjs, and TransportService.mjs.

Structural Pre-Flight: future authoring of ai/mcp/server/shared/services/RuntimeFreshnessService.mjs qualifies for the structural fast-path: it matches the sibling pattern of shared MCP services in ai/mcp/server/shared/services/; sibling-file-lift applies; no novel directory choice. Map maintenance: not needed unless the implementation introduces a new directory or a broader runtime subsystem description.

The Fix

Extract the runtime freshness helper/service behind one shared module and migrate the three existing consumers to it.

Expected shape:

  • Shared module owns file digest helpers, boot identity capture, current identity read/caching, compact stale classification, and test seams.
  • Each consumer provides only service-specific inputs: root directory, relevant identity files, service display name, and restart hint text.
  • Consumer HealthService classes stay responsible for their own dependency health semantics; runtimeFreshness.status === 'stale' remains diagnostic metadata, not a top-level health failure.

Contract Ledger Matrix

Target Surface Source of Authority Proposed Behavior Fallback Docs Evidence
runtimeFreshness healthcheck block Existing #12766/#12773/#12775 healthcheck surfaces Shared helper returns compact {status, startedAt, stale, details, hint}-style diagnostics without public boot/current identity echo If identity cannot be compared, return status: 'unknown' with diagnostic detail OpenAPI schemas for each MCP server Focused unit coverage for helper + migrated consumers
Current identity read/cache #12775 peer-review feedback Avoid git/hash work on every cached healthcheck call; use a short runtimeFreshness TTL or equivalent cache-miss strategy Test seam can bypass cache or set TTL to zero JSDoc in shared helper Unit test proves cache reuse and refresh behavior
Service-specific identity inputs HealthService consumers Each service passes its own root path and relevant files; no hidden fallback values or cross-service path assumptions Missing file/root produces unknown, not throw JSDoc in consumer wiring Unit tests for missing identity reads
gitHead stale semantics Peer review on #12766/#12773/#12775 Decide once whether gitHead is a stale trigger, contextual detail, or scoped out in favor of service-owned digests Document rationale in helper JSDoc and tests PR body + helper JSDoc Tests showing unrelated-field behavior

Decision Record impact

Aligned with ADR 0019 by keeping provider/config ownership in the resolved service inputs instead of re-exporting or aliasing aiConfig. No ADR amendment expected unless the implementation changes runtime freshness semantics across service boundaries beyond helper extraction.

Acceptance Criteria

  • One shared runtime freshness helper/service exists under a structurally justified MCP-shared location.
  • GitHub Workflow, Memory Core, and Knowledge Base health services consume the shared helper instead of carrying independent classifyRuntimeFreshness/digest/cache implementations.
  • The public healthcheck payloads remain compact and do not expose full boot/current identity objects.
  • Current-identity reads are cached or computed only on cache miss/short TTL; no per-healthcheck git/hash work on the healthy cached path.
  • The gitHead stale-signal policy is decided once and covered by tests.
  • Focused unit coverage exercises the helper and at least two migrated consumers.
  • Existing healthcheck statuses remain unchanged: stale runtime freshness is diagnostic metadata, not a top-level outage.

Out of Scope

  • Changing the top-level health semantics for any MCP server.
  • Adding a new MCP tool.
  • Solving post-merge harness restart automation.
  • Reopening the #12775 Knowledge Base runtime freshness implementation unless the shared extraction requires a mechanical migration.

Related

Retrieval Hint: "runtimeFreshness shared helper MCP healthcheck classifyRuntimeFreshness gitHead stale semantics"

tobiu referenced in commit 685eab4 - "feat(ai): share MCP runtime freshness helper (#12776) (#12778) on Jun 9, 2026, 7:08 PM
tobiu closed this issue on Jun 9, 2026, 7:08 PM