feat(epic4): подтверждать durable Task после атомарного PG-commit (Story 4.2)
CI / UI Checks (pull_request) Successful in 8s
CI / Rust Checks (pull_request) Successful in 19m34s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
CI / UI Checks (pull_request) Successful in 8s
CI / Rust Checks (pull_request) Successful in 19m34s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
Application entry выдаёт Task ID только после атомарного PostgreSQL commit Task+intent+capacity; replay/conflict, owner scope, bounded envelope, terminal CAS и fail-closed readiness проверены на реальном PG. Также включён принятый план перехода на rmcp (только документ, миграция не запускается).
This commit is contained in:
1 parent
cc612516a2
commit
2219a7217d
37 files changed
+4028
-136
No files matched your search
@@ -51,12 +51,14 @@ mod auth_resolution;
|
||||
mod dispatch;
|
||||
mod endpoint;
|
||||
mod legacy_dispatch;
|
||||
mod tasks;
|
||||
|
||||
use self::approvals::{
|
||||
approve_request, deny_request, get_approval_request, list_pending_approvals,
|
||||
};
|
||||
pub(super) use self::auth_resolution::resolve_operation_auth;
|
||||
use self::endpoint::{mcp_delete, mcp_get, mcp_post};
|
||||
pub use self::tasks::{TaskApplication, TaskApplicationError, TaskPrincipal};
|
||||
|
||||
// Test-only import surface: the BUILD-internal `app/tests.rs` module reaches these two
|
||||
// through `super`, and the plain lib build does not use them (same pattern as
|
||||
@@ -92,6 +94,9 @@ pub(super) struct AppState {
|
||||
pub(super) signal_streams: Arc<crate::protocol::StreamRegistry>,
|
||||
/// Story 3.4: the bounded table of the `tools/call` requests a legacy client can still cancel.
|
||||
pub(super) in_flight: Arc<self::lifecycle::InFlightCalls>,
|
||||
/// Story 4.2: durable background Tasks over the same registry pool. The public wire stays
|
||||
/// synchronous/unsupported; readiness depends on this mandatory store.
|
||||
tasks: Arc<TaskApplication>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -137,6 +142,7 @@ pub fn build_app(
|
||||
DEFAULT_MAX_CONCURRENT_SESSIONS,
|
||||
false,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -192,6 +198,7 @@ pub fn build_app_with_background_workers_and_limits(
|
||||
max_concurrent_sessions,
|
||||
true,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -227,6 +234,41 @@ pub fn build_app_with_artifacts(
|
||||
max_concurrent_sessions,
|
||||
true,
|
||||
Some(artifact_store),
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
/// Production launcher entry point with the durable Task application entry constructed by the
|
||||
/// process composition root from the same registry pool and admission limits as the runtime.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn build_app_with_artifacts_and_tasks(
|
||||
registry: PostgresRegistry,
|
||||
refresh_interval: Duration,
|
||||
public_base_url: Option<String>,
|
||||
secret_crypto: SecretCrypto,
|
||||
runtime: RuntimeExecutor,
|
||||
api_rate_limiter: RequestRateLimiter,
|
||||
coordination_store: Arc<dyn CoordinationStateStore>,
|
||||
sessions: SharedSessionStore,
|
||||
credential_verifier: SharedMachineCredentialVerifier,
|
||||
max_concurrent_sessions: usize,
|
||||
artifact_store: crank_artifacts::ArtifactStore,
|
||||
tasks: Arc<TaskApplication>,
|
||||
) -> Router {
|
||||
build_app_inner(
|
||||
registry,
|
||||
refresh_interval,
|
||||
public_base_url,
|
||||
secret_crypto,
|
||||
runtime,
|
||||
api_rate_limiter,
|
||||
coordination_store,
|
||||
sessions,
|
||||
credential_verifier,
|
||||
max_concurrent_sessions,
|
||||
true,
|
||||
Some(artifact_store),
|
||||
Some(tasks),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -244,8 +286,23 @@ fn build_app_inner(
|
||||
max_concurrent_sessions: usize,
|
||||
start_background_workers: bool,
|
||||
artifact_store: Option<crank_artifacts::ArtifactStore>,
|
||||
tasks: Option<Arc<TaskApplication>>,
|
||||
) -> Router {
|
||||
let session_metrics = ActiveSessionMetrics::start(Arc::clone(&sessions));
|
||||
let tasks = tasks.unwrap_or_else(|| {
|
||||
let store = crank_registry::PostgresTaskStore::new(
|
||||
registry.pool().clone(),
|
||||
crank_registry::AdmissionLimits::default(),
|
||||
crank_core::AdmissionSchedulerConfig::default(),
|
||||
)
|
||||
.expect("default admission limits and scheduler weights are valid");
|
||||
Arc::new(TaskApplication::new(
|
||||
registry.clone(),
|
||||
refresh_interval,
|
||||
Arc::clone(&coordination_store),
|
||||
crank_runtime::TaskService::new(Arc::new(store)),
|
||||
))
|
||||
});
|
||||
let state = Arc::new(AppState {
|
||||
registry: registry.clone(),
|
||||
catalog: PublishedToolCatalog::new(registry, refresh_interval, coordination_store),
|
||||
@@ -263,6 +320,7 @@ fn build_app_inner(
|
||||
in_flight: Arc::new(lifecycle::InFlightCalls::new(
|
||||
lifecycle::MAX_IN_FLIGHT_CALLS,
|
||||
)),
|
||||
tasks,
|
||||
});
|
||||
if start_background_workers {
|
||||
spawn_approval_recovery(Arc::clone(&state));
|
||||
@@ -315,11 +373,17 @@ async fn readiness(State(state): State<Arc<AppState>>) -> Response {
|
||||
// Story 4.1: admission state is a mandatory dependency of every execution, so readiness must
|
||||
// reflect it rather than reporting ready on a bare `select 1`.
|
||||
let admission_ready = state.registry.execution_admission_health().await.is_ok();
|
||||
if postgres_ready && admission_ready {
|
||||
// Story 4.2: the durable Task store is mandatory for a durable acceptance acknowledgement.
|
||||
let durable_tasks_ready = state.tasks.health().await.is_ok();
|
||||
if postgres_ready && admission_ready && durable_tasks_ready {
|
||||
return Json(json!({
|
||||
"service": "mcp-server",
|
||||
"status": "ready",
|
||||
"checks": { "postgres": "ready", "execution_admission": "ready" }
|
||||
"checks": {
|
||||
"postgres": "ready",
|
||||
"execution_admission": "ready",
|
||||
"durable_tasks": "ready"
|
||||
}
|
||||
}))
|
||||
.into_response();
|
||||
}
|
||||
@@ -336,6 +400,14 @@ async fn readiness(State(state): State<Arc<AppState>>) -> Response {
|
||||
"not_ready"
|
||||
}),
|
||||
);
|
||||
checks.insert(
|
||||
"durable_tasks".to_owned(),
|
||||
json!(if durable_tasks_ready {
|
||||
"ready"
|
||||
} else {
|
||||
"not_ready"
|
||||
}),
|
||||
);
|
||||
(
|
||||
StatusCode::SERVICE_UNAVAILABLE,
|
||||
Json(json!({
|
||||
|
||||
Reference in new issue
Block a user