feat(workbench): land M00–M06 runtime contracts and read-only view

Add capabilities/selection/usage/DocumentView/locator/RunContext with
honest probes, LLM messages+cancel, sse-live cancel bridge, and CI
workbench_contracts gate; record design evidence for verified slices.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-10-25 10:55:08 +08:00
1 parent 663a8ba2c0
commit 03396afd02
41 files changed
+2997 -68

No files matched your search

@@ -0,0 +1,20 @@
{
"schema": "DocumentViewV1",
"schema_version": 1,
"document": {
"id": "knowledge/example.mq.md",
"title": "知识标题",
"source_revision": "sha256:requested-source",
"semantic_digest": "sha256:semantic-facts",
"generation_id": null,
"presentation_token": "opaque-token"
},
"execution": {"state": "not_run", "run_id": null},
"render": {"format": "sanitized_html", "fragment": "<article class=\"mq-document\"></article>", "renderer_version": "1"},
"outline": [],
"nodes": [],
"refs": [],
"diagnostics": [{"code": "partial", "message": "missing dependency"}],
"completeness": "partial",
"capabilities": {"read_only": true, "has_semantics": true, "executed": false}
}
@@ -0,0 +1,8 @@
{
"ok": false,
"error": {
"code": "view.document_unsupported_format",
"message": "binary formats require extract adapter",
"retryable": false
}
}
@@ -0,0 +1,19 @@
{
"schema": "KnowledgeLocatorV1",
"schema_version": 1,
"resolution": "stale",
"precision": "document",
"locator": {
"schema": "KnowledgeLocatorV1",
"schema_version": 1,
"project_id": "/authorized/project",
"document_id": "knowledge/example.mq.md",
"source_revision": "sha256:old",
"artifact_id": "mq://project/example/function",
"relation": "cites"
},
"target": null,
"candidates": [],
"diagnostics": [{"code": "source_revision_mismatch", "message": "expected sha256:old, actual sha256:new"}],
"label": "该来源已变化"
}
@@ -0,0 +1,19 @@
{
"schema": "KnowledgeLocatorV1",
"schema_version": 1,
"resolution": "version_unavailable",
"precision": "none",
"locator": {
"schema": "KnowledgeLocatorV1",
"schema_version": 1,
"project_id": "/authorized/project",
"document_id": "knowledge/example.mq.md",
"generation_id": "generation-missing",
"artifact_id": "mq://project/example/function",
"relation": "cites"
},
"target": null,
"candidates": [],
"diagnostics": [{"code": "generation_unavailable", "message": "snapshot not retained"}],
"label": "引用版本不可用"
}
@@ -0,0 +1,26 @@
{
"schema": "ModelCallUsageV1",
"schema_version": 1,
"call_id": "call-2",
"attempt_id": "attempt-1",
"parent_call_id": null,
"run_id": "run-1",
"turn_id": "turn-1",
"workspace_scope": "ws-1",
"purpose": "answer",
"selection_id": "sel-1",
"provider_id": "provider-1",
"model_id": "model-2",
"requested_model": "example-model",
"resolved_model": "example-model",
"status": "cancelled",
"usage_state": "partial",
"measurement_source": "provider",
"input_tokens": 100,
"output_tokens": 12,
"total_tokens": 112,
"cached_input_tokens": null,
"reasoning_output_tokens": null,
"revision": 2,
"diagnostics": []
}
@@ -0,0 +1,26 @@
{
"schema": "ModelCallUsageV1",
"schema_version": 1,
"call_id": "call-1",
"attempt_id": "attempt-1",
"parent_call_id": null,
"run_id": "run-1",
"turn_id": "turn-1",
"workspace_scope": "ws-1",
"purpose": "answer",
"selection_id": "sel-1",
"provider_id": "provider-1",
"model_id": "model-2",
"requested_model": "example-model",
"resolved_model": "example-model",
"status": "succeeded",
"usage_state": "unknown",
"measurement_source": "none",
"input_tokens": null,
"output_tokens": null,
"total_tokens": null,
"cached_input_tokens": null,
"reasoning_output_tokens": null,
"revision": 1,
"diagnostics": []
}
@@ -0,0 +1,12 @@
{
"schema": "ModelSelectionV1",
"schema_version": 1,
"error": {
"code": "llm.selection_missing",
"message": "selection_id required in strict mode",
"retryable": false
},
"partial": {
"model_id": "model-2"
}
}
@@ -0,0 +1,17 @@
{
"schema": "ModelSelectionV1",
"schema_version": 1,
"selection_id": "sel-1",
"provider_id": "provider-1",
"model_id": "model-2",
"provider_revision": 3,
"model_revision": 5,
"adapter": "openai-compatible",
"endpoint_ref": "endpoint-local-1",
"credential_ref": "credential-local-1",
"credential_version": 2,
"upstream_model_id": "example-model",
"parameters": {"max_output_tokens": 2048},
"fallback_policy": "disabled",
"auth_mode": "api_key"
}
@@ -0,0 +1,13 @@
{
"schema": "RuntimeEventV1",
"schema_version": 1,
"event_id": "evt-9",
"seq": 9,
"run_id": "run-1",
"parent_run_id": null,
"turn_id": "turn-1",
"workspace_scope": "ws-1",
"timestamp": "2026-10-25T01:00:04Z",
"type": "run.cancelled",
"payload": {"reason": "user_stop", "usage_state": "partial"}
}
@@ -0,0 +1,38 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "marqdo://contracts/DocumentViewV1",
"title": "DocumentViewV1",
"type": "object",
"required": ["schema", "schema_version", "document", "execution", "completeness"],
"properties": {
"schema": { "const": "DocumentViewV1" },
"schema_version": { "const": 1 },
"document": {
"type": "object",
"required": ["id", "source_revision"],
"properties": {
"id": { "type": "string" },
"title": { "type": "string" },
"source_revision": { "type": "string" },
"semantic_digest": { "type": "string" },
"generation_id": { "type": ["string", "null"] },
"presentation_token": { "type": "string" }
}
},
"execution": {
"type": "object",
"required": ["state"],
"properties": {
"state": { "const": "not_run" },
"run_id": { "type": ["string", "null"] }
}
},
"completeness": { "enum": ["complete", "partial"] },
"render": { "type": "object" },
"outline": { "type": "array" },
"nodes": { "type": "array" },
"refs": { "type": "array" },
"diagnostics": { "type": "array" }
},
"additionalProperties": true
}
@@ -0,0 +1,29 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "marqdo://contracts/KnowledgeLocatorV1",
"title": "KnowledgeLocatorV1",
"type": "object",
"required": ["schema_version", "project_id", "document_id"],
"properties": {
"schema": { "const": "KnowledgeLocatorV1" },
"schema_version": { "const": 1 },
"project_id": { "type": "string" },
"document_id": { "type": "string" },
"source_revision": { "type": ["string", "null"] },
"generation_id": { "type": ["string", "null"] },
"artifact_id": { "type": ["string", "null"] },
"node_id": { "type": ["string", "null"] },
"relation": { "type": "string" },
"resolution": {
"enum": [
"resolved",
"stale",
"unresolved",
"ambiguous",
"version_unavailable",
"unsupported"
]
}
},
"additionalProperties": true
}
@@ -0,0 +1,32 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "marqdo://contracts/ModelCallUsageV1",
"title": "ModelCallUsageV1",
"type": "object",
"required": [
"schema_version",
"call_id",
"attempt_id",
"run_id",
"status",
"usage_state",
"measurement_source"
],
"properties": {
"schema": { "const": "ModelCallUsageV1" },
"schema_version": { "const": 1 },
"call_id": { "type": "string", "minLength": 1 },
"attempt_id": { "type": "string", "minLength": 1 },
"run_id": { "type": "string", "minLength": 1 },
"status": {
"enum": ["started", "succeeded", "failed", "cancelled", "interrupted"]
},
"usage_state": { "enum": ["pending", "partial", "final", "unknown"] },
"measurement_source": { "enum": ["provider", "estimated", "none"] },
"input_tokens": { "type": ["integer", "null"], "minimum": 0 },
"output_tokens": { "type": ["integer", "null"], "minimum": 0 },
"total_tokens": { "type": ["integer", "null"], "minimum": 0 },
"revision": { "type": "integer", "minimum": 1 }
},
"additionalProperties": true
}
@@ -0,0 +1,32 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "marqdo://contracts/ModelSelectionV1",
"title": "ModelSelectionV1",
"type": "object",
"required": [
"schema_version",
"selection_id",
"provider_id",
"model_id",
"adapter",
"upstream_model_id"
],
"properties": {
"schema": { "const": "ModelSelectionV1" },
"schema_version": { "const": 1 },
"selection_id": { "type": "string", "minLength": 1 },
"provider_id": { "type": "string", "minLength": 1 },
"model_id": { "type": "string", "minLength": 1 },
"adapter": { "type": "string" },
"upstream_model_id": { "type": "string", "minLength": 1 },
"provider_revision": { "type": ["integer", "null"] },
"model_revision": { "type": ["integer", "null"] },
"endpoint_ref": { "type": ["string", "null"] },
"credential_ref": { "type": ["string", "null"] },
"credential_version": { "type": ["integer", "null"] },
"parameters": { "type": "object" },
"fallback_policy": { "type": "string" },
"auth_mode": { "type": "string" }
},
"additionalProperties": true
}
@@ -0,0 +1,25 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "marqdo://contracts/RuntimeEventV1",
"title": "RuntimeEventV1",
"type": "object",
"required": [
"schema_version",
"event_id",
"seq",
"run_id",
"type",
"payload"
],
"properties": {
"schema": { "const": "RuntimeEventV1" },
"schema_version": { "const": 1 },
"event_id": { "type": "string", "minLength": 1 },
"seq": { "type": "integer", "minimum": 0 },
"run_id": { "type": "string", "minLength": 1 },
"type": { "type": "string", "minLength": 1 },
"payload": { "type": "object" },
"timestamp": { "type": "string" }
},
"additionalProperties": true
}