fix(mcp): invalidate review session state on cross-profile activation (Closes #690)
A mid-run profile switch (reviewer -> author -> reviewer) left workflow-load proof, reviewer lease binding, the review decision lock, live namespace health, and preflight identity/capability stamps intact, so a formal verdict could be recorded under contaminated session state. - gitea_activate_profile now invalidates all review-critical session state on a cross-profile switch, in memory and in durable state keyed by either profile identity, and reports the invalidation + re-preflight requirement. - Full reviewer preflight (whoami, load_review_workflow, resolve_task_capability(review_pr), head re-pin, lease re-acquire) is required before any formal verdict after a switch; switching back cannot resurrect the stale run. - Namespace provenance: optional launcher-declared GITEA_MCP_NAMESPACE is reported by whoami/runtime context/capability resolution, and a declared namespace that disagrees with a task's required namespace fails closed. - Docs: supported pattern is separate session/namespace per role, not in-process profile hopping mid-review.
This commit is contained in:
@@ -86,3 +86,24 @@ When a namespace returns EOF, follow
|
||||
|
||||
When blocked, repair the IDE namespace and re-record a healthy
|
||||
`client_namespace` assessment before retrying the mutation.
|
||||
|
||||
## Namespace provenance (#690)
|
||||
|
||||
A server process cannot derive the name of the client-managed namespace it is
|
||||
registered under, so the launcher may declare it with the
|
||||
`GITEA_MCP_NAMESPACE` environment variable (e.g. `GITEA_MCP_NAMESPACE=gitea-reviewer`).
|
||||
|
||||
- `gitea_whoami`, `gitea_get_runtime_context`, and
|
||||
`gitea_resolve_task_capability` report `namespace_provenance`: the declared
|
||||
client namespace, the active execution profile, and — for tasks with a
|
||||
required namespace (`review_pr`/`submit_review` → `gitea-reviewer`,
|
||||
`merge_pr` → `gitea-merger`) — a `mismatch` verdict.
|
||||
- A declared namespace that disagrees with the requested task's required
|
||||
namespace **fails closed** (`allowed_in_current_session=false` with a STOP
|
||||
guidance entry).
|
||||
- An undeclared namespace is reported as `namespace_source="unknown"` and is
|
||||
never treated as proof either way.
|
||||
- A profile switch via `gitea_activate_profile` clears all recorded live
|
||||
namespace-health assessments; re-probe through the client before further
|
||||
review/merge mutations.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user