Skip to content

Commit fe70cab

Browse files
oryan-blockclaude
andcommitted
Fail the bounded check for a container kind it never builds
A new ContainerKind with a stubbed value step compiled and passed every test, because Check.java keeps its own list of containers. The test now passes TypeShape's container types to the check, which stops with a MODEL ERROR naming each one Check.java has no Container for. The verify-return-value-unwrapping skill named ReturnValueUnwrapper, PotentialMatch and GenericTypeResolver in its trigger, coverage table and sync command. It now names TypeShape, so a change there triggers the skill and shows up in its staleness check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 6d41328 commit fe70cab

5 files changed

Lines changed: 27 additions & 11 deletions

File tree

‎.claude/skills/verify-return-value-unwrapping/SKILL.md‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: verify-return-value-unwrapping
3-
description: Exhaustively check, up to a bound, that the value of a resolver method, public field or typed Map reaches graphql-java fully unwrapped. Futures are awaited, generic wrappers are transformed, Optional and DataFetcherResult are handled, and list order, nulls and failures are kept, for every return type nested up to 3 containers deep. Use it before pushing any change to ReturnValueUnwrapper, TypeClassMatcher's unwrapping, GenericTypeResolver.resolve, the data fetchers in MethodFieldResolver, PropertyFieldResolver or MapFieldResolver, or the GenericWrapper defaults, and whenever a bug report says graphql-java got a CompletableFuture, Optional or wrapper object as a field value.
3+
description: Exhaustively check, up to a bound, that the value of a resolver method, public field or typed Map reaches graphql-java fully unwrapped. Futures are awaited, generic wrappers are transformed, Optional and DataFetcherResult are handled, and list order, nulls and failures are kept, for every return type nested up to 3 containers deep. Use it before pushing any change to TypeShape (the type walk, ContainerKind, the generic wrapper rules or the Unwrapper), the data fetchers in MethodFieldResolver, PropertyFieldResolver or MapFieldResolver, or the GenericWrapper defaults, and whenever a bug report says graphql-java got a CompletableFuture, Optional or wrapper object as a field value.
44
---
55

66
# Verify return value unwrapping
@@ -73,7 +73,7 @@ as `-Dunwrapping.args`, and prints the report. On a failure it also prints the p
7373
|---|---|
7474
| 0 | `PASS`, or `PASS apart from the known findings above` |
7575
| 1 | `FAIL`: a return type that isn't a known finding breaks the property. `NEW`: a known finding matches more accepted return types than its line records |
76-
| 2 | `MODEL ERROR`: the checkout or the check didn't compile, or the build rejected a return type the check must exercise, so a pass would prove nothing |
76+
| 2 | `MODEL ERROR`: the checkout or the check didn't compile, the build rejected a return type the check must exercise, or a `ContainerKind` in `TypeShape.kt` has no `Container` in `Check.java`, so a pass would prove nothing |
7777
| 3 | `STALE`: a known finding matches a return type that no longer fails, or fewer accepted return types than its line records |
7878

7979
Options: `--depth N`, `--budget N`, `--property-budget N`, `--show N` (counterexamples and stale return types printed, default 15), and `--rejected`, which lists
@@ -157,25 +157,24 @@ or delete it when none fail, so that a regression shows up as `FAIL`.
157157

158158
## Coverage and sync
159159

160-
Last confirmed to describe the code at commit `af9ba4ad` (agent-friendly, 2026-11-04). It covers:
160+
Last confirmed to describe the code at commit `6d41328d` (2026-11-05). It covers:
161161

162162
| File | What |
163163
|---|---|
164-
| `src/main/kotlin/graphql/kickstart/tools/resolver/ReturnValueUnwrapper.kt` | all of it |
165-
| `src/main/kotlin/graphql/kickstart/tools/TypeClassMatcher.kt` | `PotentialMatch.unwrap`, `Unwrapped` |
166-
| `src/main/kotlin/graphql/kickstart/tools/GenericTypeResolver.kt` | `resolve`, `resolveTypeVariables` |
167-
| `src/main/kotlin/graphql/kickstart/tools/resolver/MethodFieldResolver.kt` | `createDataFetcher` (`valueClass`, the unwrapper), `returnType`, `returnValueMatch`, `LightMethodFieldResolverDataFetcher` |
164+
| `src/main/kotlin/graphql/kickstart/tools/resolver/TypeShape.kt` | all of it: the walk, `ContainerKind`, `GenericWrappers`, `resolveTypeVariables`, the `Unwrapper` and its steps |
165+
| `src/main/kotlin/graphql/kickstart/tools/resolver/MethodFieldResolver.kt` | `createDataFetcher` (the `TypeShape.Unwrapper`), `returnShape`, `LightMethodFieldResolverDataFetcher` |
168166
| `src/main/kotlin/graphql/kickstart/tools/SchemaParserOptions.kt` | `GenericWrapper` and the default wrappers in `build()` |
169167
| `src/main/kotlin/graphql/kickstart/tools/resolver/PropertyFieldResolver.kt` | all of it |
170168
| `src/main/kotlin/graphql/kickstart/tools/resolver/MapFieldResolver.kt` | all of it, for Map subclasses with a typed value |
171169

172170
To see whether a change needs another look:
173171

174172
```bash
175-
git log --oneline af9ba4ad..HEAD -- src/main/kotlin/graphql/kickstart/tools/resolver/ReturnValueUnwrapper.kt src/main/kotlin/graphql/kickstart/tools/TypeClassMatcher.kt src/main/kotlin/graphql/kickstart/tools/GenericTypeResolver.kt src/main/kotlin/graphql/kickstart/tools/resolver/MethodFieldResolver.kt src/main/kotlin/graphql/kickstart/tools/SchemaParserOptions.kt src/main/kotlin/graphql/kickstart/tools/resolver/PropertyFieldResolver.kt src/main/kotlin/graphql/kickstart/tools/resolver/MapFieldResolver.kt
173+
git log --oneline 6d41328d..HEAD -- src/main/kotlin/graphql/kickstart/tools/resolver/TypeShape.kt src/main/kotlin/graphql/kickstart/tools/resolver/MethodFieldResolver.kt src/main/kotlin/graphql/kickstart/tools/SchemaParserOptions.kt src/main/kotlin/graphql/kickstart/tools/resolver/PropertyFieldResolver.kt src/main/kotlin/graphql/kickstart/tools/resolver/MapFieldResolver.kt
176174
```
177175

178176
Move the sync commit forward only after you've read those changes and confirmed that the containers, variants and
179177
expected values in `Check.java` still describe them. For example, a new default wrapper or a new kind of unwrapping
180-
step needs a new `Container` with its variants and its plain value in `build`. After an intended change, rerun the check,
178+
step needs a new `Container` with its variants and its plain value in `build`. A new `ContainerKind` ends in
179+
`MODEL ERROR` until it has one. After an intended change, rerun the check,
181180
and break the new code on purpose once in a scratch worktree to see the check fail before you trust its pass.

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ happening. "docs only" means nothing does yet, so the rule depends on you readin
9090

9191
| Rule | Enforced by |
9292
|---|---|
93-
| A resolver method's return value is unwrapped by one rule that the schema build and the data fetcher share | `TypeShape`, whose one walk yields both the class the schema build matches and the layers the data fetcher unwraps. A container kind can't be added without its placement rule and its value step, since both are abstract on the enum |
93+
| A resolver method's return value is unwrapped by one rule that the schema build and the data fetcher share | `TypeShape`, whose one walk yields both the class the schema build matches and the layers the data fetcher unwraps. A container kind can't be added without its placement rule and its value step, since both are abstract on the enum, and `ReturnValueUnwrappingTest` fails until the bounded check builds values for it |
9494
| A resolver method's parameter layout, type variables and source are decided once, at schema build | docs only |
9595
| A change to how resolvers are found, bound or unwrapped keeps what a method, a property and a Map field return | `ResolverCompatibilityTest` and the bounded check in `ReturnValueUnwrappingTest`. Each lists exactly today's property and Map gaps as known findings, and fails when one is fixed until it's removed, or when a new failure would hide under one |
9696
| One output has one builder. Don't add a second path that builds the same thing | docs only |

‎src/main/kotlin/graphql/kickstart/tools/resolver/TypeShape.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ internal class TypeShape private constructor(
8989
}
9090

9191
companion object {
92+
val containerTypes: List<Class<*>> get() = ContainerKind.entries.map { it.type }
93+
9294
fun returnType(
9395
graphQLType: GraphQLLangType,
9496
declaredType: JavaType,

‎src/test/kotlin/graphql/kickstart/tools/returnvalue/ReturnValueUnwrappingTest.kt‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package graphql.kickstart.tools.returnvalue
22

3+
import graphql.kickstart.tools.resolver.TypeShape
34
import org.junit.Assert.fail
45
import org.junit.Test
56
import java.io.ByteArrayOutputStream
@@ -21,7 +22,10 @@ class ReturnValueUnwrappingTest {
2122
compile(classpath, dir, copy("Check.java", dir), copy("Fixtures.java", dir))
2223

2324
val args = System.getProperty("unwrapping.args", "").split(" ").filter { it.isNotBlank() } +
24-
listOf("--known", copy("known-findings.txt", dir).toString())
25+
listOf(
26+
"--known", copy("known-findings.txt", dir).toString(),
27+
"--container-kinds", TypeShape.containerTypes.joinToString(",") { it.canonicalName }
28+
)
2529
val report = ByteArrayOutputStream()
2630
val passed = URLClassLoader(arrayOf(dir.toUri().toURL()), javaClass.classLoader).use { loader ->
2731
PrintStream(report, true, Charsets.UTF_8).use { out ->

‎src/test/resources/returnvalue/Check.java‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,17 @@ public static boolean check(String[] args, String classpath, PrintStream out) th
312312
int show = intArg(args, "--show", 15);
313313
long started = System.nanoTime();
314314

315+
Set<String> built = Arrays.stream(Container.values()).map(it -> it.javaName).collect(Collectors.toSet());
316+
List<String> unchecked = Arrays.stream(stringArg(args, "--container-kinds").split(","))
317+
.filter(it -> !built.contains(it))
318+
.collect(Collectors.toList());
319+
if (!unchecked.isEmpty()) {
320+
out.println("MODEL ERROR: TypeShape.kt has a ContainerKind for these classes, but no Container in Check.java builds them, so a pass would prove nothing about them:");
321+
unchecked.forEach(it -> out.println(" " + it));
322+
out.println("Add a Container for each to Check.java with its value variants, and its plain value in build.");
323+
return false;
324+
}
325+
315326
List<Case> cases = cases(depth);
316327
Map<String, Class<?>> resolvers = compile(cases, classpath);
317328

0 commit comments

Comments
 (0)