Commit Graph
1 Commits
Author SHA1 Message Date
5948b20741 feat(analyzer): parse and validate Analyzer responses (#17) (#61)
Add compiler/analyzer/response_parser.py: parse_scene_response(text, logger=None)
-> CompilerResult, per MASTER_SPEC §12.2, §12.8.

- Strictly json.loads the model response; JSON is never repaired heuristically
  (§12.9), so malformed or markdown-fenced output fails here (feeding the retry
  path in #18).
- Validates the parsed document against the Scene schema; any failure (malformed
  JSON, non-object, missing field, wrong type) is reported as SC0011 and stops
  the compilation -- invalid responses are never silently accepted.
- Handles both object and string concept forms via the Scene model; confidence
  stays metadata-only.
- Stamps a default schema_version onto compiler-owned metadata (the model emits
  `"metadata": {}`) before validation.

Tests: valid response -> Scene, metadata stamping, object/string concepts +
confidence, and rejection (SC0011) of malformed JSON, non-object JSON, missing
fields, wrong types, and markdown-fenced (unrepaired) output.

Co-authored-by: kunail0804 <kunail0804@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 13:54:39 +02:00