diff --git a/README.md b/README.md index efc2e11..6b7c454 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # Code Intelligence Protocol -Public data formats for the standalone Genesis Code Intelligence product. The source Pydantic models and deterministic schema exporter live in the private `GenesisAgentInfra/code-intelligence` repository; generated JSON Schema files in this repository must not be edited by hand. +Public data formats for the standalone Genesis Code Intelligence product. The source Pydantic models and deterministic schema exporter live in the public `GenesisAgentInfra/genesis-cli` repository; generated JSON Schema files in this repository must not be edited by hand. ## Contents - `schemas/v0.1.0/analysis-response.schema.json`: stable, user-readable Markdown/JSON report contract. +- `schemas/v0.3.0/analysis-response.schema.json`: opt-in report with revision-specific, evidence-backed semantic execution paths. - `schemas/v0.2.0/analysis-response.schema.json`: opt-in report with source-backed business behavior comparisons; all v0.1.0 report fields remain. - `schemas/v0.1.0/flows.schema.json`: machine-readable `.genesis/flows.yaml` contract. - `specs/flows-yaml.md`: lifecycle and field semantics. @@ -14,7 +15,9 @@ Public data formats for the standalone Genesis Code Intelligence product. The so The four reports demonstrate a complete result, unresolved dynamic call, missing intent/tests, and stale flow entry. They are protocol examples, not evidence of analyzer accuracy. -Internal CLI-to-service requests, source excerpts, analysis facts, semantic service responses, API keys, and usage records are private implementation details and are not part of this public protocol. +The open-source CLI implements local extraction and API delivery; the hosted semantic service is maintained separately. CLI-to-service request internals are not a stable public report contract. Customer source excerpts, API keys and usage records are confidential and do not belong in this repository. + +Start with [genesis-cli](https://github.com/GenesisAgentInfra/genesis-cli) for installation and usage. This repository documents data formats. The JSON Schema format is Draft 2020-12. Report schema, private request protocol, and flow-file schema have separate versions. Report completeness describes only declared analysis coverage; it does not mean a test passed or a change is approved. diff --git a/examples/v0.3.0/execution-paths.json b/examples/v0.3.0/execution-paths.json new file mode 100644 index 0000000..1f009c7 --- /dev/null +++ b/examples/v0.3.0/execution-paths.json @@ -0,0 +1,406 @@ +{ + "schema_version": "0.3.0", + "snapshot_id": "sha256:348c1be73023373ed0e1804deaf4efb2933ec349da1c0c9dd295457a56e7f83d", + "analysis_status": "partial", + "section_status": { + "behavior_intent": { + "status": "analyzed", + "reason": null, + "analyzed_scope": "Synthetic submit_report example only" + }, + "flow_impact": { + "status": "analyzed", + "reason": null, + "analyzed_scope": "Synthetic submit_report example only" + }, + "cost_risk": { + "status": "analyzed", + "reason": null, + "analyzed_scope": "Synthetic submit_report example only" + }, + "acceptance_tests": { + "status": "analyzed", + "reason": null, + "analyzed_scope": "Synthetic submit_report example only" + }, + "verification": { + "status": "analyzed", + "reason": null, + "analyzed_scope": "Synthetic submit_report example only" + } + }, + "scope": { + "base_revision": "fixture-normal-five-sections-base", + "head_revision": "fixture-normal-five-sections-head", + "analyzed_files": [ + ".genesis/flows.yaml", + "intent/pr.md", + "intent/task.md", + "src/app.py", + "tests/test_submit.py" + ], + "omitted_inputs": [], + "parser_limitations": [ + "Deterministic fixture facts; no customer code was analyzed." + ], + "execution_mode": "mock" + }, + "findings": [ + { + "finding_id": "F-RULE-WAIT", + "category": "cost_risk", + "statement": "An awaited operation was added before returning; actual added wait is unknown.", + "severity": "low", + "basis": [ + "code_fact" + ], + "evidence_ids": [ + "ev_89e203f9043afb89b9068091", + "ev_6df63ca95d3cb58b96f6d1f7" + ], + "deviation": null, + "condition": null, + "gap": null, + "recommendation": null, + "flow_ids": [], + "estimate_ids": [ + "wait-1" + ] + }, + { + "finding_id": "F-SEM-BEHAVIOR", + "category": "behavior_intent", + "statement": "The head function awaits notify(result) before returning; the base function returns submission directly.", + "severity": "info", + "basis": [ + "code_fact" + ], + "evidence_ids": [ + "ev_89e203f9043afb89b9068091", + "ev_6df63ca95d3cb58b96f6d1f7" + ], + "deviation": null, + "condition": null, + "gap": null, + "recommendation": null, + "flow_ids": [], + "estimate_ids": [] + }, + { + "finding_id": "F-SEM-CLAIM", + "category": "behavior_intent", + "statement": "No success-value check appears before notify in the visible function. If submit returns a failure value instead of raising, the PR's claim is unverified.", + "severity": "medium", + "basis": [ + "code_fact", + "user_intent", + "agent_claim", + "semantic_inference" + ], + "evidence_ids": [ + "ev_6df63ca95d3cb58b96f6d1f7", + "ev_1e751d22d466cffdc5bcb9c1", + "ev_5dd9203ab8839a14297b8fa5" + ], + "deviation": "unverified_claim", + "condition": "Only when submit returns a failure value; exceptions prevent the following notify call.", + "gap": null, + "recommendation": null, + "flow_ids": [], + "estimate_ids": [] + }, + { + "finding_id": "F-SEM-TEST", + "category": "acceptance_tests", + "statement": "The supplied test checks a non-null result; it contains no assertion about notification on failure.", + "severity": "low", + "basis": [ + "code_fact", + "user_intent" + ], + "evidence_ids": [ + "ev_6faad0b1bdfff9c9b6261e4d", + "ev_1e751d22d466cffdc5bcb9c1" + ], + "deviation": null, + "condition": null, + "gap": null, + "recommendation": null, + "flow_ids": [ + "submit-report" + ], + "estimate_ids": [] + } + ], + "estimates": [ + { + "estimate_id": "wait-1", + "flow_ids": [], + "structural_signals": [ + "One additional serial await" + ], + "parameters": [ + { + "name": "added_wait", + "value": null, + "unit": "ms", + "source": null, + "unknown_reason": "No runtime measurements or external implementation supplied" + } + ], + "formula": null, + "amount": null, + "currency": null, + "price_source": null, + "price_date": null, + "assumptions": [], + "unknowns": [ + "Actual latency and failure rate" + ], + "evidence_ids": [ + "ev_89e203f9043afb89b9068091", + "ev_6df63ca95d3cb58b96f6d1f7" + ] + } + ], + "suggestions": [ + { + "suggestion_id": "V-001", + "scenario": "Review the new awaited operation's failure behavior.", + "conditions": [ + "Submission returns a failure value", + "Submission raises an exception" + ], + "suggested_assertions": [ + "No success notification is sent on a failure-valued submission" + ], + "existing_test_evidence_ids": [ + "ev_6faad0b1bdfff9c9b6261e4d" + ], + "rationale": "Distinguish return-value failures from exceptions; test definitions are not executed.", + "questions_for_user": [ + "Which values mean submission failed?", + "Should an awaited operation's failure change the return behavior?" + ], + "evidence_ids": [ + "ev_6df63ca95d3cb58b96f6d1f7" + ] + } + ], + "limitations": [ + { + "code": "mock_fixture", + "message": "Synthetic contract example, not a customer analysis.", + "evidence_ids": [], + "affects_completeness": false + } + ], + "analyzer_version": "0.1.0-mock", + "rule_version": "0.1.0-mock", + "semantic_version": "mock-v1", + "evidence": [ + { + "evidence_id": "ev_89e203f9043afb89b9068091", + "snapshot_id": "sha256:348c1be73023373ed0e1804deaf4efb2933ec349da1c0c9dd295457a56e7f83d", + "side": "base", + "path": "src/app.py", + "range": { + "start_line": 1, + "end_line": 2, + "start_column": null, + "end_column": null + }, + "snippet_digest": "sha256:37b82a7da7a16b0788e23b4481e4f79fdac7b17ecaf2e99cb643878a0178751e", + "kind": "code" + }, + { + "evidence_id": "ev_6df63ca95d3cb58b96f6d1f7", + "snapshot_id": "sha256:348c1be73023373ed0e1804deaf4efb2933ec349da1c0c9dd295457a56e7f83d", + "side": "head", + "path": "src/app.py", + "range": { + "start_line": 1, + "end_line": 4, + "start_column": null, + "end_column": null + }, + "snippet_digest": "sha256:bfb2ed982e86a11e90c1e514342e5378eaac2b75437d1c6332fb9cc990b5ace7", + "kind": "code" + }, + { + "evidence_id": "ev_17747a64e05ffff55266df1b", + "snapshot_id": "sha256:348c1be73023373ed0e1804deaf4efb2933ec349da1c0c9dd295457a56e7f83d", + "side": "base", + "path": ".genesis/flows.yaml", + "range": { + "start_line": 1, + "end_line": 9, + "start_column": null, + "end_column": null + }, + "snippet_digest": "sha256:04a254461546fece9246c49f90901dce5e7407b985dbb599a05f9d3aca706f3e", + "kind": "flow" + }, + { + "evidence_id": "ev_afc8b812c5a4c2486e9283c2", + "snapshot_id": "sha256:348c1be73023373ed0e1804deaf4efb2933ec349da1c0c9dd295457a56e7f83d", + "side": "head", + "path": ".genesis/flows.yaml", + "range": { + "start_line": 1, + "end_line": 9, + "start_column": null, + "end_column": null + }, + "snippet_digest": "sha256:04a254461546fece9246c49f90901dce5e7407b985dbb599a05f9d3aca706f3e", + "kind": "flow" + }, + { + "evidence_id": "ev_5dd9203ab8839a14297b8fa5", + "snapshot_id": "sha256:348c1be73023373ed0e1804deaf4efb2933ec349da1c0c9dd295457a56e7f83d", + "side": "head", + "path": "intent/pr.md", + "range": { + "start_line": 1, + "end_line": 1, + "start_column": null, + "end_column": null + }, + "snippet_digest": "sha256:9929b358104171c1c3c15fa719949cc0fa90baa9dc76a3aca2a807f486ad2084", + "kind": "intent" + }, + { + "evidence_id": "ev_1e751d22d466cffdc5bcb9c1", + "snapshot_id": "sha256:348c1be73023373ed0e1804deaf4efb2933ec349da1c0c9dd295457a56e7f83d", + "side": "head", + "path": "intent/task.md", + "range": { + "start_line": 1, + "end_line": 1, + "start_column": null, + "end_column": null + }, + "snippet_digest": "sha256:4a4c4ab25ce9fae85ba0e59458dedadb0d3329f785da9fbc875538ff1a4cb5b9", + "kind": "intent" + }, + { + "evidence_id": "ev_6faad0b1bdfff9c9b6261e4d", + "snapshot_id": "sha256:348c1be73023373ed0e1804deaf4efb2933ec349da1c0c9dd295457a56e7f83d", + "side": "head", + "path": "tests/test_submit.py", + "range": { + "start_line": 1, + "end_line": 3, + "start_column": null, + "end_column": null + }, + "snippet_digest": "sha256:ff9704d3f8a48bd8fe000b634911b152aea5abf8870bb8b8317e9a090b20fba4", + "kind": "test" + } + ], + "behavior_review": { + "version": "2", + "coverage": { + "status": "insufficient_context", + "reason": "Synthetic example; caller and notification implementation are absent.", + "analyzed_scope": null + }, + "changes": [ + { + "change_id": "report-notification", + "scenario": "提交报告并通知", + "condition": "按各版本的调用方式执行 submit_report,第三方提交返回结果。", + "before": "直接返回第三方提交结果。", + "after": "等待通知完成后才返回提交结果;函数现在需要异步调用。", + "before_evidence_ids": [ + "ev_89e203f9043afb89b9068091" + ], + "after_evidence_ids": [ + "ev_6df63ca95d3cb58b96f6d1f7" + ], + "explanation": "新增 await notify(result),放在提交与返回之间。", + "impact": "完成时间包含通知等待;若通知抛出异常,当前函数不会正常返回结果。", + "preserved_behavior": "第三方提交调用仍是同步调用。", + "evidence_ids": [ + "ev_89e203f9043afb89b9068091", + "ev_6df63ca95d3cb58b96f6d1f7" + ], + "finding_ids": [], + "limitations": [ + "未提供调用方及通知实现,无法确认调用方适配、通知耗时及失败概率。" + ] + } + ], + "paths": [ + { + "path_id": "base-submit", + "side": "base", + "scenario": "Submit a report.", + "condition": "Submission returns normally.", + "entry_step_id": "submit", + "steps": [ + { + "step_id": "submit", + "symbol": "src/app.py#submit_report", + "kind": "entrypoint", + "description": "Submit a report.", + "evidence_ids": [ + "ev_89e203f9043afb89b9068091" + ] + } + ], + "links": [], + "outcome": "Return the submission result directly.", + "limitations": [ + "Only the synthetic function body is represented; caller and notification implementation are omitted." + ] + }, + { + "path_id": "head-submit", + "side": "head", + "scenario": "Submit a report.", + "condition": "Submission returns normally.", + "entry_step_id": "submit", + "steps": [ + { + "step_id": "submit", + "symbol": "src/app.py#submit_report", + "kind": "entrypoint", + "description": "Submit a report.", + "evidence_ids": [ + "ev_6df63ca95d3cb58b96f6d1f7" + ] + }, + { + "step_id": "notify", + "symbol": null, + "kind": "external", + "description": "Await the notification before returning.", + "evidence_ids": [ + "ev_6df63ca95d3cb58b96f6d1f7" + ] + } + ], + "links": [ + { + "source": "submit", + "target": "notify", + "relation": "await", + "condition": "Submission returned a result.", + "support": "semantic_inference", + "evidence_ids": [ + "ev_6df63ca95d3cb58b96f6d1f7" + ], + "limitations": [ + "The notification implementation is not supplied." + ] + } + ], + "outcome": "Return the submission result after notification.", + "limitations": [ + "Only the synthetic function body is represented; caller and notification implementation are omitted." + ] + } + ] + } +} diff --git a/schemas/v0.3.0/analysis-response.schema.json b/schemas/v0.3.0/analysis-response.schema.json new file mode 100644 index 0000000..b8c7adb --- /dev/null +++ b/schemas/v0.3.0/analysis-response.schema.json @@ -0,0 +1,1184 @@ +{ + "$defs": { + "AnalysisScope": { + "additionalProperties": false, + "properties": { + "analyzed_files": { + "items": { + "type": "string" + }, + "title": "Analyzed Files", + "type": "array" + }, + "base_revision": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Base Revision" + }, + "execution_mode": { + "enum": [ + "mock", + "offline", + "semantic" + ], + "title": "Execution Mode", + "type": "string" + }, + "head_revision": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Head Revision" + }, + "omitted_inputs": { + "default": [], + "items": { + "type": "string" + }, + "title": "Omitted Inputs", + "type": "array" + }, + "parser_limitations": { + "default": [], + "items": { + "type": "string" + }, + "title": "Parser Limitations", + "type": "array" + } + }, + "required": [ + "analyzed_files", + "execution_mode" + ], + "title": "AnalysisScope", + "type": "object" + }, + "AnalysisStatus": { + "enum": [ + "complete", + "partial", + "failed" + ], + "title": "AnalysisStatus", + "type": "string" + }, + "BehaviorChange": { + "additionalProperties": false, + "description": "Source-backed semantic comparison, never an inferred user requirement.", + "properties": { + "after": { + "anyOf": [ + { + "maxLength": 2000, + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "After" + }, + "after_evidence_ids": { + "default": [], + "items": { + "type": "string" + }, + "maxItems": 16, + "title": "After Evidence Ids", + "type": "array" + }, + "before": { + "anyOf": [ + { + "maxLength": 2000, + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Before" + }, + "before_evidence_ids": { + "default": [], + "items": { + "type": "string" + }, + "maxItems": 16, + "title": "Before Evidence Ids", + "type": "array" + }, + "change_id": { + "maxLength": 128, + "minLength": 1, + "title": "Change Id", + "type": "string" + }, + "condition": { + "maxLength": 1000, + "minLength": 1, + "title": "Condition", + "type": "string" + }, + "evidence_ids": { + "items": { + "type": "string" + }, + "maxItems": 24, + "minItems": 1, + "title": "Evidence Ids", + "type": "array" + }, + "explanation": { + "maxLength": 2000, + "minLength": 1, + "title": "Explanation", + "type": "string" + }, + "finding_ids": { + "default": [], + "items": { + "type": "string" + }, + "maxItems": 24, + "title": "Finding Ids", + "type": "array" + }, + "impact": { + "maxLength": 2000, + "minLength": 1, + "title": "Impact", + "type": "string" + }, + "limitations": { + "default": [], + "items": { + "type": "string" + }, + "maxItems": 8, + "title": "Limitations", + "type": "array" + }, + "preserved_behavior": { + "anyOf": [ + { + "maxLength": 1000, + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Preserved Behavior" + }, + "scenario": { + "maxLength": 500, + "minLength": 1, + "title": "Scenario", + "type": "string" + } + }, + "required": [ + "change_id", + "scenario", + "condition", + "explanation", + "impact", + "evidence_ids" + ], + "title": "BehaviorChange", + "type": "object" + }, + "CapabilityStatus": { + "additionalProperties": false, + "properties": { + "analyzed_scope": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Analyzed Scope" + }, + "reason": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Reason" + }, + "status": { + "$ref": "#/$defs/SectionStatus" + } + }, + "required": [ + "status" + ], + "title": "CapabilityStatus", + "type": "object" + }, + "EstimateParameter": { + "additionalProperties": false, + "properties": { + "name": { + "title": "Name", + "type": "string" + }, + "source": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Source" + }, + "unit": { + "title": "Unit", + "type": "string" + }, + "unknown_reason": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Unknown Reason" + }, + "value": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Value" + } + }, + "required": [ + "name", + "value", + "unit" + ], + "title": "EstimateParameter", + "type": "object" + }, + "EvidenceBasis": { + "enum": [ + "code_fact", + "semantic_inference", + "conditional_estimate", + "user_intent", + "agent_claim" + ], + "title": "EvidenceBasis", + "type": "string" + }, + "EvidenceKind": { + "enum": [ + "code", + "intent", + "flow", + "test", + "config" + ], + "title": "EvidenceKind", + "type": "string" + }, + "EvidenceRef": { + "additionalProperties": false, + "properties": { + "evidence_id": { + "minLength": 1, + "title": "Evidence Id", + "type": "string" + }, + "kind": { + "$ref": "#/$defs/EvidenceKind" + }, + "path": { + "minLength": 1, + "title": "Path", + "type": "string" + }, + "range": { + "$ref": "#/$defs/ReferenceRange" + }, + "side": { + "$ref": "#/$defs/EvidenceSide" + }, + "snapshot_id": { + "minLength": 1, + "title": "Snapshot Id", + "type": "string" + }, + "snippet_digest": { + "pattern": "^sha256:[0-9a-f]{64}$", + "title": "Snippet Digest", + "type": "string" + } + }, + "required": [ + "evidence_id", + "snapshot_id", + "side", + "path", + "range", + "snippet_digest", + "kind" + ], + "title": "EvidenceRef", + "type": "object" + }, + "EvidenceSide": { + "enum": [ + "base", + "head" + ], + "title": "EvidenceSide", + "type": "string" + }, + "ExecutionLink": { + "additionalProperties": false, + "properties": { + "condition": { + "anyOf": [ + { + "maxLength": 500, + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Condition" + }, + "evidence_ids": { + "items": { + "type": "string" + }, + "maxItems": 8, + "minItems": 1, + "title": "Evidence Ids", + "type": "array" + }, + "limitations": { + "default": [], + "items": { + "type": "string" + }, + "maxItems": 4, + "title": "Limitations", + "type": "array" + }, + "relation": { + "enum": [ + "call", + "await", + "branch", + "return", + "raise", + "human_wait" + ], + "title": "Relation", + "type": "string" + }, + "source": { + "maxLength": 128, + "minLength": 1, + "title": "Source", + "type": "string" + }, + "support": { + "default": "semantic_inference", + "enum": [ + "semantic_inference", + "unknown" + ], + "title": "Support", + "type": "string" + }, + "target": { + "maxLength": 128, + "minLength": 1, + "title": "Target", + "type": "string" + } + }, + "required": [ + "source", + "target", + "relation", + "evidence_ids" + ], + "title": "ExecutionLink", + "type": "object" + }, + "ExecutionPath": { + "additionalProperties": false, + "description": "Semantic explanation of one revision, distinct from the static call graph.", + "properties": { + "condition": { + "maxLength": 500, + "minLength": 1, + "title": "Condition", + "type": "string" + }, + "entry_step_id": { + "anyOf": [ + { + "maxLength": 128, + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Entry Step Id" + }, + "limitations": { + "default": [], + "items": { + "type": "string" + }, + "maxItems": 8, + "title": "Limitations", + "type": "array" + }, + "links": { + "default": [], + "items": { + "$ref": "#/$defs/ExecutionLink" + }, + "maxItems": 16, + "title": "Links", + "type": "array" + }, + "outcome": { + "anyOf": [ + { + "maxLength": 500, + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Outcome" + }, + "path_id": { + "maxLength": 128, + "minLength": 1, + "title": "Path Id", + "type": "string" + }, + "scenario": { + "maxLength": 500, + "minLength": 1, + "title": "Scenario", + "type": "string" + }, + "side": { + "$ref": "#/$defs/EvidenceSide" + }, + "steps": { + "items": { + "$ref": "#/$defs/ExecutionStep" + }, + "maxItems": 12, + "minItems": 1, + "title": "Steps", + "type": "array" + } + }, + "required": [ + "path_id", + "side", + "scenario", + "condition", + "steps" + ], + "title": "ExecutionPath", + "type": "object" + }, + "ExecutionStep": { + "additionalProperties": false, + "properties": { + "description": { + "maxLength": 500, + "minLength": 1, + "title": "Description", + "type": "string" + }, + "evidence_ids": { + "items": { + "type": "string" + }, + "maxItems": 8, + "minItems": 1, + "title": "Evidence Ids", + "type": "array" + }, + "kind": { + "enum": [ + "entrypoint", + "function", + "model", + "tool", + "human", + "external", + "return", + "raise" + ], + "title": "Kind", + "type": "string" + }, + "step_id": { + "maxLength": 128, + "minLength": 1, + "title": "Step Id", + "type": "string" + }, + "symbol": { + "anyOf": [ + { + "maxLength": 500, + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Symbol" + } + }, + "required": [ + "step_id", + "kind", + "description", + "evidence_ids" + ], + "title": "ExecutionStep", + "type": "object" + }, + "Finding": { + "additionalProperties": false, + "properties": { + "basis": { + "items": { + "$ref": "#/$defs/EvidenceBasis" + }, + "minItems": 1, + "title": "Basis", + "type": "array" + }, + "category": { + "$ref": "#/$defs/FindingCategory" + }, + "condition": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Condition" + }, + "deviation": { + "anyOf": [ + { + "$ref": "#/$defs/IntentDeviation" + }, + { + "type": "null" + } + ], + "default": null + }, + "estimate_ids": { + "default": [], + "items": { + "type": "string" + }, + "title": "Estimate Ids", + "type": "array" + }, + "evidence_ids": { + "items": { + "type": "string" + }, + "title": "Evidence Ids", + "type": "array" + }, + "finding_id": { + "minLength": 1, + "title": "Finding Id", + "type": "string" + }, + "flow_ids": { + "default": [], + "items": { + "type": "string" + }, + "title": "Flow Ids", + "type": "array" + }, + "gap": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Gap" + }, + "recommendation": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Recommendation" + }, + "severity": { + "$ref": "#/$defs/Severity" + }, + "statement": { + "minLength": 1, + "title": "Statement", + "type": "string" + } + }, + "required": [ + "finding_id", + "category", + "statement", + "severity", + "basis", + "evidence_ids" + ], + "title": "Finding", + "type": "object" + }, + "FindingCategory": { + "enum": [ + "behavior_intent", + "flow_impact", + "cost_risk", + "acceptance_tests", + "verification" + ], + "title": "FindingCategory", + "type": "string" + }, + "ImpactEstimate": { + "additionalProperties": false, + "properties": { + "amount": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Amount" + }, + "assumptions": { + "default": [], + "items": { + "type": "string" + }, + "title": "Assumptions", + "type": "array" + }, + "currency": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Currency" + }, + "estimate_id": { + "title": "Estimate Id", + "type": "string" + }, + "evidence_ids": { + "items": { + "type": "string" + }, + "title": "Evidence Ids", + "type": "array" + }, + "flow_ids": { + "default": [], + "items": { + "type": "string" + }, + "title": "Flow Ids", + "type": "array" + }, + "formula": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Formula" + }, + "parameters": { + "default": [], + "items": { + "$ref": "#/$defs/EstimateParameter" + }, + "title": "Parameters", + "type": "array" + }, + "price_date": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Price Date" + }, + "price_source": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Price Source" + }, + "structural_signals": { + "default": [], + "items": { + "type": "string" + }, + "title": "Structural Signals", + "type": "array" + }, + "unknowns": { + "default": [], + "items": { + "type": "string" + }, + "title": "Unknowns", + "type": "array" + } + }, + "required": [ + "estimate_id", + "evidence_ids" + ], + "title": "ImpactEstimate", + "type": "object" + }, + "IntentDeviation": { + "enum": [ + "missing_in_code", + "unrequested_change", + "unverified_claim" + ], + "title": "IntentDeviation", + "type": "string" + }, + "Limitation": { + "additionalProperties": false, + "properties": { + "affects_completeness": { + "default": false, + "title": "Affects Completeness", + "type": "boolean" + }, + "code": { + "title": "Code", + "type": "string" + }, + "evidence_ids": { + "default": [], + "items": { + "type": "string" + }, + "title": "Evidence Ids", + "type": "array" + }, + "message": { + "title": "Message", + "type": "string" + } + }, + "required": [ + "code", + "message" + ], + "title": "Limitation", + "type": "object" + }, + "PathBehaviorReview": { + "additionalProperties": false, + "properties": { + "changes": { + "default": [], + "items": { + "$ref": "#/$defs/BehaviorChange" + }, + "maxItems": 12, + "title": "Changes", + "type": "array" + }, + "coverage": { + "$ref": "#/$defs/CapabilityStatus" + }, + "paths": { + "items": { + "$ref": "#/$defs/ExecutionPath" + }, + "maxItems": 6, + "title": "Paths", + "type": "array" + }, + "version": { + "const": "2", + "default": "2", + "title": "Version", + "type": "string" + } + }, + "required": [ + "coverage", + "paths" + ], + "title": "PathBehaviorReview", + "type": "object" + }, + "ReferenceRange": { + "additionalProperties": false, + "properties": { + "end_column": { + "anyOf": [ + { + "minimum": 0, + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "title": "End Column" + }, + "end_line": { + "minimum": 1, + "title": "End Line", + "type": "integer" + }, + "start_column": { + "anyOf": [ + { + "minimum": 0, + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Start Column" + }, + "start_line": { + "minimum": 1, + "title": "Start Line", + "type": "integer" + } + }, + "required": [ + "start_line", + "end_line" + ], + "title": "ReferenceRange", + "type": "object" + }, + "SectionStatus": { + "enum": [ + "analyzed", + "insufficient_context", + "unsupported" + ], + "title": "SectionStatus", + "type": "string" + }, + "SectionStatuses": { + "additionalProperties": false, + "properties": { + "acceptance_tests": { + "$ref": "#/$defs/CapabilityStatus" + }, + "behavior_intent": { + "$ref": "#/$defs/CapabilityStatus" + }, + "cost_risk": { + "$ref": "#/$defs/CapabilityStatus" + }, + "flow_impact": { + "$ref": "#/$defs/CapabilityStatus" + }, + "verification": { + "$ref": "#/$defs/CapabilityStatus" + } + }, + "required": [ + "behavior_intent", + "flow_impact", + "cost_risk", + "acceptance_tests", + "verification" + ], + "title": "SectionStatuses", + "type": "object" + }, + "Severity": { + "enum": [ + "info", + "low", + "medium", + "high" + ], + "title": "Severity", + "type": "string" + }, + "VerificationSuggestion": { + "additionalProperties": false, + "properties": { + "conditions": { + "default": [], + "items": { + "type": "string" + }, + "title": "Conditions", + "type": "array" + }, + "evidence_ids": { + "items": { + "type": "string" + }, + "title": "Evidence Ids", + "type": "array" + }, + "existing_test_evidence_ids": { + "default": [], + "items": { + "type": "string" + }, + "title": "Existing Test Evidence Ids", + "type": "array" + }, + "questions_for_user": { + "default": [], + "items": { + "type": "string" + }, + "title": "Questions For User", + "type": "array" + }, + "rationale": { + "minLength": 1, + "title": "Rationale", + "type": "string" + }, + "scenario": { + "minLength": 1, + "title": "Scenario", + "type": "string" + }, + "suggested_assertions": { + "default": [], + "items": { + "type": "string" + }, + "title": "Suggested Assertions", + "type": "array" + }, + "suggestion_id": { + "title": "Suggestion Id", + "type": "string" + } + }, + "required": [ + "suggestion_id", + "scenario", + "rationale", + "evidence_ids" + ], + "title": "VerificationSuggestion", + "type": "object" + } + }, + "additionalProperties": false, + "properties": { + "analysis_status": { + "$ref": "#/$defs/AnalysisStatus" + }, + "analyzer_version": { + "minLength": 1, + "title": "Analyzer Version", + "type": "string" + }, + "behavior_review": { + "$ref": "#/$defs/PathBehaviorReview" + }, + "estimates": { + "default": [], + "items": { + "$ref": "#/$defs/ImpactEstimate" + }, + "title": "Estimates", + "type": "array" + }, + "evidence": { + "items": { + "$ref": "#/$defs/EvidenceRef" + }, + "title": "Evidence", + "type": "array" + }, + "findings": { + "default": [], + "items": { + "$ref": "#/$defs/Finding" + }, + "title": "Findings", + "type": "array" + }, + "limitations": { + "default": [], + "items": { + "$ref": "#/$defs/Limitation" + }, + "title": "Limitations", + "type": "array" + }, + "rule_version": { + "minLength": 1, + "title": "Rule Version", + "type": "string" + }, + "schema_version": { + "const": "0.3.0", + "default": "0.3.0", + "title": "Schema Version", + "type": "string" + }, + "scope": { + "$ref": "#/$defs/AnalysisScope" + }, + "section_status": { + "$ref": "#/$defs/SectionStatuses" + }, + "semantic_version": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Semantic Version" + }, + "snapshot_id": { + "minLength": 1, + "title": "Snapshot Id", + "type": "string" + }, + "suggestions": { + "default": [], + "items": { + "$ref": "#/$defs/VerificationSuggestion" + }, + "title": "Suggestions", + "type": "array" + } + }, + "required": [ + "snapshot_id", + "analysis_status", + "section_status", + "scope", + "analyzer_version", + "rule_version", + "evidence", + "behavior_review" + ], + "title": "PathAnalysisResponse", + "type": "object" +} diff --git a/scripts/validate_examples.py b/scripts/validate_examples.py index edfb3d3..fb27ede 100644 --- a/scripts/validate_examples.py +++ b/scripts/validate_examples.py @@ -62,6 +62,30 @@ def check_refs(value): assert (change["before"] is not None and change["after"] is not None) or change["limitations"] if report["analysis_status"] == "complete": assert report["behavior_review"]["coverage"]["status"] == "analyzed" + path_schema = json.loads((ROOT / "schemas/v0.3.0/analysis-response.schema.json").read_text()) + Draft202012Validator.check_schema(path_schema) + path_reports = sorted((ROOT / "examples/v0.3.0").glob("*.json")) + assert path_reports + for path in path_reports: + report = json.loads(path.read_text()) + Draft202012Validator(path_schema).validate(report) + assert report["scope"]["execution_mode"] == "mock" + refs = {ref["evidence_id"]: ref for ref in report["evidence"]} + paths = report["behavior_review"]["paths"] + assert len({item["path_id"] for item in paths}) == len(paths) + for item in paths: + steps = {step["step_id"]: step for step in item["steps"]} + assert len(steps) == len(item["steps"]) + assert item["entry_step_id"] in steps or (item["entry_step_id"] is None and item["limitations"]) + for node in [*item["steps"], *item["links"]]: + assert all(refs[ident]["side"] == item["side"] and refs[ident]["kind"] == "code" for ident in node["evidence_ids"]) + for step in item["steps"]: + if step["symbol"] is not None: + assert "#" in step["symbol"] + assert any(refs[ident]["path"] == step["symbol"].split("#", 1)[0] for ident in step["evidence_ids"]) + for link in item["links"]: + assert link["source"] in steps and link["target"] in steps + assert link["support"] != "unknown" or link["limitations"] flows = yaml.safe_load((ROOT / "examples/v0.1.0/flows.yaml").read_text()) validators["flows"].validate(flows) assert len({flow["id"] for flow in flows["flows"]}) == len(flows["flows"]) diff --git a/specs/behavior-comparison.md b/specs/behavior-comparison.md index 38009ed..75b21f3 100644 --- a/specs/behavior-comparison.md +++ b/specs/behavior-comparison.md @@ -25,3 +25,30 @@ Some constraints (reference existence, side and kind, unique change IDs, finding The concise and detailed Markdown reports are deterministic presentations of this same object. Neither renderer generates a second model answer. Internal AST/behavior-unit formats are intentionally separate from this public report contract. The synthetic example describes an asynchronous notification added between submitting a report and returning its result. Its scope is partial because the caller and notification implementation are absent. It demonstrates the format, not measured analyzer accuracy. + + +## Report v0.3.0: semantic execution paths + +Report v0.3.0 retains all original report fields and comparisons, sets +`behavior_review.version` to `2`, and requires `paths` (0–6 entries). v0.1.0 and +v0.2.0 are unchanged. Consumers should dispatch on `schema_version`. + +Each path has a unique `path_id`, a single `side` (`base` or `head`), scenario, +condition, steps (1–12), links (0–16), optional outcome and limitations. A step has +an ID, kind, description, selected code evidence and an optional `path#symbol` +location. Links reference existing step IDs and include a relation, optional +condition, evidence, `support` and limitations. Step IDs are unique within a path. +Every step/link cites code of that path's revision. A symbol's path must match +its code evidence. These constraints need semantic validation beyond JSON Schema. + +`support=semantic_inference` means a connection inferred from supplied code, not +a resolved static edge or observed execution. `support=unknown` requires an +explicit missing-link limitation. An unknown entry is `entry_step_id=null` with +a limitation; an unknown outcome remains `null`. No complete entry or successful +return is invented to connect fragments. Registration and method names alone do +not prove runtime selection. Static graphs remain separate. + +Paths explain the same analysis and do not replace findings, changes, cost, +verification or coverage. Empty paths do not imply the application has no flows. +The synthetic [example](../examples/v0.3.0/execution-paths.json) illustrates this +format without customer source or runtime measurements.