fix(onboarding): preserve identity mismatch signal
This commit is contained in:
parent
f5b66aba4a
commit
f04b80f201
@ -379,7 +379,13 @@ fn check_project_context(
|
|||||||
.get("schema_version")
|
.get("schema_version")
|
||||||
.and_then(|value| value.as_u64());
|
.and_then(|value| value.as_u64());
|
||||||
let project_id = context.get("project_id").and_then(|value| value.as_str());
|
let project_id = context.get("project_id").and_then(|value| value.as_str());
|
||||||
if version != Some(PROJECT_CONTEXT_SCHEMA_VERSION) {
|
if project_id != Some(expected_project_id) {
|
||||||
|
VerifyCheck::with_state(
|
||||||
|
"项目身份上下文",
|
||||||
|
VerifyState::Unavailable,
|
||||||
|
"`.lian-jing/context.json` 的 project_id 与炼境登记不一致——停止使用并重新 inject_mcp",
|
||||||
|
)
|
||||||
|
} else if version != Some(PROJECT_CONTEXT_SCHEMA_VERSION) {
|
||||||
VerifyCheck::with_state(
|
VerifyCheck::with_state(
|
||||||
"项目身份上下文",
|
"项目身份上下文",
|
||||||
VerifyState::VersionMismatch,
|
VerifyState::VersionMismatch,
|
||||||
@ -388,18 +394,12 @@ fn check_project_context(
|
|||||||
version, PROJECT_CONTEXT_SCHEMA_VERSION
|
version, PROJECT_CONTEXT_SCHEMA_VERSION
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else if project_id == Some(expected_project_id) {
|
} else {
|
||||||
VerifyCheck::with_state(
|
VerifyCheck::with_state(
|
||||||
"项目身份上下文",
|
"项目身份上下文",
|
||||||
VerifyState::Ready,
|
VerifyState::Ready,
|
||||||
"`.lian-jing/context.json` 与已登记 project_id 一致",
|
"`.lian-jing/context.json` 与已登记 project_id 一致",
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
VerifyCheck::with_state(
|
|
||||||
"项目身份上下文",
|
|
||||||
VerifyState::Unavailable,
|
|
||||||
"`.lian-jing/context.json` 的 project_id 与炼境登记不一致——停止使用并重新 inject_mcp",
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None if legacy
|
None if legacy
|
||||||
@ -989,6 +989,14 @@ mod tests {
|
|||||||
);
|
);
|
||||||
assert_eq!(mismatch.state, VerifyState::VersionMismatch);
|
assert_eq!(mismatch.state, VerifyState::VersionMismatch);
|
||||||
|
|
||||||
|
let identity_mismatch = check_project_context(
|
||||||
|
Some(r#"{"schema_version":0,"project_id":"another-project"}"#),
|
||||||
|
None,
|
||||||
|
"p1",
|
||||||
|
);
|
||||||
|
assert_eq!(identity_mismatch.state, VerifyState::Unavailable);
|
||||||
|
assert!(identity_mismatch.detail.contains("停止使用"));
|
||||||
|
|
||||||
let missing = check_project_context(None, None, "p1");
|
let missing = check_project_context(None, None, "p1");
|
||||||
assert_eq!(missing.state, VerifyState::Missing);
|
assert_eq!(missing.state, VerifyState::Missing);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user