Commit fb2c22d
fix(extract): a fenced answer is not discarded for an earlier object or a brace in prose
Closes #363. The JSON locator behind `extract` took the first object that parsed,
in every port. A draft object in the model's reasoning, an echoed format example
(`{"topic": "<slug>"}`) or prose with a brace (`{a set}`) therefore won, the
complete answer in the following ```json fence was never read, and with its
@required fields missing the reply was reported unusable: silently discarded,
not mis-parsed.
Selection now searches every fenced block first, then the whole reply, and takes
the first object that carries at least one declared field. A fenced object with
none of them (a fenced example) falls through the same way, so it cannot shadow
an unfenced answer either. When no object carries a declared field, the old
first-closed-else-first-open rule decides, so every reply that parsed before
parses the same and all 33 existing corpus cases keep their outcome.
Five new extract-conformance cases, from the issue's rows plus the two
fall-through directions, fail on the old locator and pass in all four engines
(Kotlin runs the Java one): TS 164, Java 298, C# 296, Python 204 extract tests.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M1mRRB1K2WdYy82kntMQdx1 parent ca784f4 commit fb2c22d
33 files changed
Lines changed: 312 additions & 15 deletions
File tree
- docs
- fixtures/extract-conformance
- json-fence-after-draft-object
- json-fence-after-format-echo
- json-fence-after-prose-brace
- json-fenced-example-then-answer
- json-shapeless-object-then-answer
- server
- csharp
- MetaObjects.Render.Tests/Extract
- MetaObjects.Render/Extract
- java/render/src/main/java/com/metaobjects/render/extract
- python
- src/metaobjects/render/extract
- tests/conformance
- typescript/packages/render
- src/extract
- test/extract
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
13 | 29 | | |
14 | 30 | | |
15 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments