Implements the hub side of the shared reuse-event schema (already drafted in WP-0018-T01, schemas/reuse-event.schema.json): a SQLite reuse_events table, POST /v1/reuse-events (token-auth), GET /v1/reuse-events?capability_id= (read-only). reuse_surface/plan_check.py: refactored record_outcome around a new shared post_or_fallback_reuse_event() helper -- tries the hub first, falls back to the local JSONL only on failure/unreachability, never both. New record_manual_reuse_event() backs a new CLI command, reuse-surface record-reuse, for retroactive facts recorded outside plan-check. Privacy/scope (repo slugs and capability ids only, no code, no secrets) is enforced structurally via the schema's additionalProperties: false, not just by convention. 21 new pytest cases, 145 total pass. Live-verified against a real running hub instance: POST/GET /v1/reuse-events directly, record-reuse and plan-check --record-outcome both posting successfully to the hub, and -- after actually killing the hub process -- confirmed the fallback path writes correctly to the local JSONL instead of erroring. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
60 lines
1.8 KiB
JSON
60 lines
1.8 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://reuse-surface.local/schemas/plan-check-result.schema.json",
|
|
"title": "PlanCheckResult",
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["query", "verdict", "top_score", "matches"],
|
|
"properties": {
|
|
"query": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["source", "text"],
|
|
"properties": {
|
|
"source": {"type": "string", "enum": ["workplan", "intent"]},
|
|
"text": {"type": "string", "minLength": 1},
|
|
"workplan_id": {"type": ["string", "null"]},
|
|
"workplan_path": {"type": ["string", "null"]}
|
|
}
|
|
},
|
|
"verdict": {
|
|
"type": "string",
|
|
"enum": ["reuse", "extend", "new"]
|
|
},
|
|
"top_score": {
|
|
"type": "number",
|
|
"minimum": 0,
|
|
"maximum": 1
|
|
},
|
|
"matches": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["id", "score", "kind"],
|
|
"properties": {
|
|
"id": {
|
|
"type": "string",
|
|
"pattern": "^capability\\.[a-z0-9]+(\\.[a-z0-9-]+)+$"
|
|
},
|
|
"score": {"type": "number", "minimum": 0, "maximum": 1},
|
|
"vector": {"type": ["string", "null"]},
|
|
"owner": {"type": ["string", "null"]},
|
|
"summary": {"type": ["string", "null"]},
|
|
"kind": {
|
|
"type": "string",
|
|
"enum": ["deterministic", "llm", "related"]
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"federated_index_updated": {"type": ["string", "null"]},
|
|
"federated_index_stale_warning": {"type": ["string", "null"]},
|
|
"notes": {
|
|
"type": "array",
|
|
"items": {"type": "string"}
|
|
},
|
|
"filed_capability_request": {"type": ["object", "null"]},
|
|
"recorded_reuse_event": {"type": ["object", "null"]}
|
|
}
|
|
}
|