fix(research): flatten source_dossier schema to correx's flat JsonSchema
The schema declared sources as an array of objects, which correx's flat JsonSchema model can't represent (JsonSchemaProperty has no nested properties). The strict config loader rejected it at startup, silently disabling the source_dossier artifact kind. Flatten sources to an array of strings (URL-prefixed per-source notes), update the gather prompt to match, and add ResearchSchemaLoadTest to guard every shipped research schema against the strict loader.
This commit is contained in:
+47
@@ -0,0 +1,47 @@
|
||||
package com.correx.core.artifacts.kind
|
||||
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.io.path.readText
|
||||
|
||||
/**
|
||||
* The research artifact schemas (docs/schemas/research_*.json, source_dossier.json) must parse with
|
||||
* the same strict deserializer the server uses to load config artifact kinds. correx's JsonSchema is
|
||||
* flat — array properties take only scalar `items` — so a schema with array-of-object items fails to
|
||||
* load at startup (silently disabling the kind). This guards every shipped research schema.
|
||||
*/
|
||||
class ResearchSchemaLoadTest {
|
||||
|
||||
private fun repoFile(relative: String): Path {
|
||||
var dir: Path? = Path.of("").toAbsolutePath()
|
||||
while (dir != null) {
|
||||
val candidate = dir.resolve(relative)
|
||||
if (candidate.exists()) return candidate
|
||||
dir = dir.parent
|
||||
}
|
||||
error("could not locate $relative")
|
||||
}
|
||||
|
||||
private fun load(name: String): JsonSchema =
|
||||
Json.decodeFromString(JsonSchema.serializer(), repoFile("docs/schemas/$name").readText())
|
||||
|
||||
@Test
|
||||
fun `research schemas parse with the strict loader`() {
|
||||
for (name in listOf("research_plan.json", "source_dossier.json", "research_report.json")) {
|
||||
val schema = load(name)
|
||||
assertEquals("object", schema.type, "$name root must be an object")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `source dossier sources is an array of strings`() {
|
||||
val sources = load("source_dossier.json").properties.getValue("sources")
|
||||
assertEquals("array", sources.type)
|
||||
assertEquals("string", sources.items?.type, "items must be scalar — the flat JsonSchema model")
|
||||
assertTrue(sources.minItems >= 1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user